docker.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. name: Docker image builds
  2. on:
  3. workflow_dispatch:
  4. push:
  5. branches: ["main"]
  6. tags: ["v*"]
  7. env:
  8. DOCKER_METADATA_SET_OUTPUT_ENV: "true"
  9. permissions:
  10. contents: read
  11. packages: write
  12. attestations: write
  13. id-token: write
  14. pull-requests: write
  15. jobs:
  16. build:
  17. runs-on: ubuntu-24.04
  18. steps:
  19. - name: Checkout code
  20. uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
  21. with:
  22. fetch-tags: true
  23. fetch-depth: 0
  24. persist-credentials: false
  25. - name: build essential
  26. run: |
  27. sudo apt-get update
  28. sudo apt-get install -y build-essential
  29. - name: Set lowercase image name
  30. run: |
  31. echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
  32. - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
  33. with:
  34. node-version: "24.11.0"
  35. - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
  36. with:
  37. go-version: "1.25.4"
  38. - uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
  39. - name: Log into registry
  40. uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
  41. with:
  42. registry: ghcr.io
  43. username: ${{ github.repository_owner }}
  44. password: ${{ secrets.GITHUB_TOKEN }}
  45. - name: Docker meta
  46. id: meta
  47. uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
  48. with:
  49. images: ${{ env.IMAGE }}
  50. - name: Build and push
  51. id: build
  52. run: |
  53. npm ci
  54. npm run container
  55. env:
  56. DOCKER_REPO: ${{ env.IMAGE }}
  57. SLOG_LEVEL: debug
  58. - name: Generate artifact attestation
  59. uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
  60. with:
  61. subject-name: ${{ env.IMAGE }}
  62. subject-digest: ${{ steps.build.outputs.digest }}
  63. push-to-registry: true