build-publish-dispatch.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. name: Build and publish Docker images on demand
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. image_tag:
  6. description: "Image tag"
  7. type: string
  8. required: true
  9. jobs:
  10. multiarch-build:
  11. name: Build and publish ${{ matrix.base }} image with tag ${{ inputs.image_tag }}
  12. strategy:
  13. matrix:
  14. base: [alpine, debian]
  15. runs-on: ubuntu-latest
  16. steps:
  17. - name: Checkout
  18. uses: actions/checkout@v4
  19. with:
  20. fetch-depth: 0
  21. - name: Retrieve nginx-proxy version
  22. id: nginx-proxy_version
  23. run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
  24. - name: Retrieve docker-gen version
  25. id: docker-gen_version
  26. run: sed -n -e 's;^FROM docker.io/nginxproxy/docker-gen:\([0-9.]*\).*;VERSION=\1;p' Dockerfile.${{ matrix.base }} >> "$GITHUB_OUTPUT"
  27. - name: Get Docker tags
  28. id: docker_meta
  29. uses: docker/metadata-action@v5
  30. with:
  31. images: |
  32. nginxproxy/nginx-proxy
  33. tags: |
  34. type=raw,value=${{ inputs.image_tag }},enable=${{ matrix.base == 'debian' }}
  35. type=raw,value=${{ inputs.image_tag }},suffix=-alpine,enable=${{ matrix.base == 'alpine' }}
  36. labels: |
  37. org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
  38. org.opencontainers.image.version=${{ steps.nginx-proxy_version.outputs.VERSION }}
  39. flavor: |
  40. latest=false
  41. - name: Set up QEMU
  42. uses: docker/setup-qemu-action@v3
  43. - name: Set up Docker Buildx
  44. uses: docker/setup-buildx-action@v3
  45. - name: Login to DockerHub
  46. uses: docker/login-action@v3
  47. with:
  48. username: ${{ secrets.DOCKERHUB_USERNAME }}
  49. password: ${{ secrets.DOCKERHUB_TOKEN }}
  50. - name: Log in to GitHub Container Registry
  51. uses: docker/login-action@v3
  52. with:
  53. registry: ghcr.io
  54. username: ${{ github.actor }}
  55. password: ${{ secrets.GITHUB_TOKEN }}
  56. - name: Build and push the image
  57. id: docker_build
  58. uses: docker/build-push-action@v6
  59. with:
  60. context: .
  61. file: Dockerfile.${{ matrix.base }}
  62. build-args: |
  63. NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
  64. DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
  65. platforms: linux/amd64,linux/arm64,linux/s390x,linux/arm/v7
  66. sbom: true
  67. push: true
  68. provenance: mode=max
  69. tags: ${{ steps.docker_meta.outputs.tags }}
  70. labels: ${{ steps.docker_meta.outputs.labels }}
  71. cache-from: type=gha
  72. cache-to: type=gha,mode=max
  73. - name: Images digests
  74. run: echo ${{ steps.docker_build.outputs.digest }}