build-push-pr.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. platforms: linux/amd64,linux/arm64
  30. use_native_arm64_builder: true
  31. push_to_images: |
  32. ghcr.io/mastodon/mastodon
  33. version_metadata: ${{ needs.compute-suffix.outputs.metadata }}
  34. flavor: |
  35. latest=auto
  36. tags: |
  37. type=ref,event=pr
  38. secrets: inherit