docker-publish.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. 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 Container registry
  21. uses: docker/login-action@v3
  22. with:
  23. registry: ${{ env.REGISTRY }}
  24. username: ${{ github.actor }}
  25. password: ${{ secrets.GITHUB_TOKEN }}
  26. - name: Extract metadata for Docker build
  27. id: meta
  28. uses: docker/metadata-action@v5
  29. with:
  30. images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
  31. flavor: latest=true
  32. tags: |
  33. type=semver,pattern={{version}}
  34. type=semver,pattern={{major}}
  35. type=semver,pattern={{major}}.{{minor}}
  36. type=schedule,prefix=nightly-,pattern={{date 'YYYYMMDD'}}
  37. type=raw,enable=${{ github.event_name == 'workflow_dispatch' }},value=workflow_dispatch-{{branch}}-{{sha}}
  38. type=raw,enable=${{ github.event_name == 'release' }},value=stable
  39. - name: Set up QEMU
  40. uses: docker/setup-qemu-action@v3
  41. with:
  42. platforms: arm64
  43. - name: Set up Docker Buildx
  44. uses: docker/setup-buildx-action@v3
  45. - name: Build and push Docker image
  46. uses: docker/build-push-action@v6
  47. with:
  48. context: .
  49. build-args: DEPENDENCIES=bcrypt,argon2,ldap
  50. push: true
  51. tags: ${{ steps.meta.outputs.tags }}
  52. labels: ${{ steps.meta.outputs.labels }}
  53. platforms: linux/amd64,linux/arm64