2
0

build-publish-dispatch.yml 2.8 KB

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