build-publish-dispatch.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 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. ghcr.io/nginx-proxy/nginx-proxy
  33. nginxproxy/nginx-proxy
  34. jwilder/nginx-proxy
  35. tags: |
  36. type=raw,value=${{ inputs.image_tag }},enable=${{ matrix.base == 'debian' }}
  37. type=raw,value=${{ inputs.image_tag }},suffix=-alpine,enable=${{ matrix.base == 'alpine' }}
  38. labels: |
  39. org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
  40. org.opencontainers.image.version=${{ steps.nginx-proxy_version.outputs.VERSION }}
  41. flavor: |
  42. latest=false
  43. - name: Set up QEMU
  44. uses: docker/setup-qemu-action@v3
  45. - name: Set up Docker Buildx
  46. uses: docker/setup-buildx-action@v3
  47. - name: Login to DockerHub
  48. uses: docker/login-action@v3
  49. with:
  50. username: ${{ secrets.DOCKERHUB_USERNAME }}
  51. password: ${{ secrets.DOCKERHUB_TOKEN }}
  52. - name: Log in to GitHub Container Registry
  53. uses: docker/login-action@v3
  54. with:
  55. registry: ghcr.io
  56. username: ${{ github.actor }}
  57. password: ${{ secrets.GITHUB_TOKEN }}
  58. - name: Build and push the image
  59. id: docker_build
  60. uses: docker/build-push-action@v6
  61. with:
  62. context: .
  63. file: Dockerfile.${{ matrix.base }}
  64. build-args: |
  65. NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
  66. DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
  67. platforms: linux/amd64,linux/arm64,linux/s390x,linux/arm/v7
  68. sbom: true
  69. push: true
  70. provenance: mode=max
  71. tags: ${{ steps.docker_meta.outputs.tags }}
  72. labels: ${{ steps.docker_meta.outputs.labels }}
  73. cache-from: type=gha
  74. cache-to: type=gha,mode=max
  75. - name: Images digests
  76. run: echo ${{ steps.docker_build.outputs.digest }}