1
0

container-image.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ---
  2. name: container image
  3. on:
  4. push:
  5. pull_request:
  6. schedule:
  7. - cron: '0 20 * * 5'
  8. jobs:
  9. docker-build:
  10. runs-on: ubuntu-22.04
  11. permissions: {packages: write}
  12. steps:
  13. - id: meta
  14. # > "automatic" tag management and OCI Image Format Spec… for labels
  15. # https://web.archive.org/web/20250103123053/https://docs.docker.com/build/ci/github-actions/manage-tags-labels/
  16. uses: docker/metadata-action@v5
  17. with:
  18. # see comment on `push: true` below
  19. images: ghcr.io/${{ github.repository_owner }}/systemctl-mqtt
  20. # https://web.archive.org/web/20250103130404/https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
  21. tags: |
  22. type=semver,pattern={{version}}
  23. type=ref,event=branch
  24. type=ref,event=pr
  25. type=sha,format=long
  26. type=raw,value=latest,enable=false
  27. - uses: docker/setup-qemu-action@v3.3.0
  28. - uses: docker/login-action@v3
  29. with:
  30. registry: ghcr.io
  31. username: ${{ github.actor }}
  32. password: ${{ secrets.GITHUB_TOKEN }}
  33. # > setup-buildx action … is not required but recommended using it to be
  34. # > able to build multi-platform images, export cache, etc.
  35. # https://web.archive.org/web/20250103122420/https://github.com/marketplace/actions/build-and-push-docker-images
  36. - uses: docker/setup-buildx-action@v3.8.0
  37. # > By default, this action uses the Git context so you don't need to use
  38. # > the actions/checkout action to checkout the repository because this
  39. # > will be done directly by buildkit. [...]
  40. # > any file mutation in the steps that precede [...] will be ignored,
  41. # > including processing of the .dockerignore file
  42. # https://github.com/marketplace/actions/build-and-push-docker-images
  43. # > The commit history is not preserved.
  44. # https://docs.docker.com/engine/reference/commandline/build/#git-repositories
  45. - uses: docker/build-push-action@v6.12.0
  46. with:
  47. build-args: | # git history unavailable (see above)
  48. SETUPTOOLS_SCM_PRETEND_VERSION=0
  49. platforms: |
  50. linux/amd64
  51. linux/arm/v6
  52. linux/arm/v7
  53. linux/arm64
  54. # > Require approval for all external contributors
  55. # > All users that are not a member or owner of this repository will
  56. # > require approval to run workflows.
  57. # https://github.com/fphammerle/systemctl-mqtt/settings/actions
  58. push: true
  59. tags: ${{ steps.meta.outputs.tags }}
  60. labels: ${{ steps.meta.outputs.labels }}