container-image.yml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. images: ghcr.io/${{ github.actor }}/systemctl-mqtt
  19. # https://web.archive.org/web/20250103130404/https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input
  20. tags: |
  21. type=semver,pattern={{version}}
  22. type=ref,event=branch
  23. type=ref,event=pr
  24. type=sha,format=long
  25. type=raw,value=latest,enable=false
  26. - uses: docker/setup-qemu-action@v3.2.0
  27. - uses: docker/login-action@v3
  28. with:
  29. registry: ghcr.io
  30. username: ${{ github.actor }}
  31. password: ${{ secrets.GITHUB_TOKEN }}
  32. # > setup-buildx action … is not required but recommended using it to be
  33. # > able to build multi-platform images, export cache, etc.
  34. # https://web.archive.org/web/20250103122420/https://github.com/marketplace/actions/build-and-push-docker-images
  35. - uses: docker/setup-buildx-action@v3.8.0
  36. # > By default, this action uses the Git context so you don't need to use
  37. # > the actions/checkout action to checkout the repository because this
  38. # > will be done directly by buildkit. [...]
  39. # > any file mutation in the steps that precede [...] will be ignored,
  40. # > including processing of the .dockerignore file
  41. # https://github.com/marketplace/actions/build-and-push-docker-images
  42. # > The commit history is not preserved.
  43. # https://docs.docker.com/engine/reference/commandline/build/#git-repositories
  44. - uses: docker/build-push-action@v6.10.0
  45. with:
  46. build-args: | # git history unavailable (see above)
  47. SETUPTOOLS_SCM_PRETEND_VERSION=0
  48. platforms: |
  49. linux/amd64
  50. linux/arm/v6
  51. linux/arm/v7
  52. linux/arm64
  53. push: true
  54. tags: ${{ steps.meta.outputs.tags }}
  55. labels: ${{ steps.meta.outputs.labels }}