docker-publish.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Build and publish Docker image
  2. on:
  3. release:
  4. types: [released]
  5. schedule:
  6. - cron: '0 0 * * *'
  7. workflow_dispatch:
  8. env:
  9. GHCR_REGISTRY: ghcr.io
  10. IMAGE_NAME: ${{ github.repository }}
  11. jobs:
  12. build-and-push-image:
  13. runs-on: ubuntu-latest
  14. permissions:
  15. contents: read
  16. packages: write
  17. steps:
  18. - name: Checkout repository
  19. uses: actions/checkout@v4
  20. - name: Log in to the ghcr container registry
  21. uses: docker/login-action@v3
  22. with:
  23. registry: ${{ env.GHCR_REGISTRY }}
  24. username: ${{ github.actor }}
  25. password: ${{ secrets.GITHUB_TOKEN }}
  26. - name: Log in to the dockerhub container registry
  27. uses: docker/login-action@v3
  28. with:
  29. username: ${{ vars.DOCKERHUB_ORGNAME }}
  30. password: ${{ secrets.DOCKERHUB_TOKEN }}
  31. - name: Extract metadata for Docker build
  32. id: meta
  33. uses: docker/metadata-action@v5
  34. with:
  35. images: |
  36. name=${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
  37. name=${{ env.IMAGE_NAME }}
  38. flavor: latest=true
  39. tags: |
  40. type=semver,pattern={{version}}
  41. type=semver,pattern={{major}}
  42. type=semver,pattern={{major}}.{{minor}}
  43. type=schedule,prefix=nightly-,pattern={{date 'YYYYMMDD'}}
  44. type=raw,enable=${{ github.event_name == 'workflow_dispatch' }},value=workflow_dispatch-{{branch}}-{{sha}}
  45. type=raw,enable=${{ github.event_name == 'release' }},value=stable
  46. - name: Set up QEMU
  47. uses: docker/setup-qemu-action@v3
  48. with:
  49. platforms: arm64
  50. - name: Set up Docker Buildx
  51. uses: docker/setup-buildx-action@v3
  52. - name: Build and push Docker image
  53. uses: docker/build-push-action@v6
  54. with:
  55. context: .
  56. build-args: DEPENDENCIES=bcrypt,argon2,ldap
  57. push: true
  58. tags: ${{ steps.meta.outputs.tags }}
  59. labels: ${{ steps.meta.outputs.labels }}
  60. platforms: linux/amd64,linux/arm64