build-push-pr.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: Build container image for PR
  2. on:
  3. pull_request:
  4. types: [labeled, synchronize, reopened, ready_for_review, opened]
  5. permissions:
  6. contents: read
  7. packages: write
  8. jobs:
  9. compute-suffix:
  10. runs-on: ubuntu-latest
  11. # This is only allowed to run if:
  12. # - the PR branch is in the `mastodon/mastodon` repository
  13. # - the PR is not a draft
  14. # - the PR has the "build-image" label
  15. if: ${{ github.event.pull_request.head.repo.full_name == github.repository && !github.event.pull_request.draft && contains(github.event.pull_request.labels.*.name, 'build-image') }}
  16. steps:
  17. # Repository needs to be cloned so `git rev-parse` below works
  18. - name: Clone repository
  19. uses: actions/checkout@v4
  20. - id: version_vars
  21. run: |
  22. echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
  23. outputs:
  24. metadata: ${{ steps.version_vars.outputs.mastodon_version_metadata }}
  25. build-image:
  26. needs: compute-suffix
  27. uses: ./.github/workflows/build-container-image.yml
  28. with:
  29. file_to_build: Dockerfile
  30. platforms: linux/amd64,linux/arm64
  31. use_native_arm64_builder: true
  32. push_to_images: |
  33. ghcr.io/mastodon/mastodon
  34. version_metadata: ${{ needs.compute-suffix.outputs.metadata }}
  35. flavor: |
  36. latest=auto
  37. tags: |
  38. type=ref,event=pr
  39. secrets: inherit
  40. build-image-streaming:
  41. needs: compute-suffix
  42. uses: ./.github/workflows/build-container-image.yml
  43. with:
  44. file_to_build: streaming/Dockerfile
  45. platforms: linux/amd64,linux/arm64
  46. use_native_arm64_builder: true
  47. push_to_images: |
  48. ghcr.io/mastodon/mastodon-streaming
  49. version_metadata: ${{ needs.compute-suffix.outputs.metadata }}
  50. flavor: |
  51. latest=auto
  52. tags: |
  53. type=ref,event=pr
  54. secrets: inherit