2023-07-18 14:36:12 +03:00
|
|
|
name: Build container image for PR
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types: [labeled, synchronize, reopened, ready_for_review, opened]
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
packages: write
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
compute-suffix:
|
|
|
|
runs-on: ubuntu-latest
|
2023-07-18 17:56:42 +03:00
|
|
|
# This is only allowed to run if:
|
|
|
|
# - the PR branch is in the `mastodon/mastodon` repository
|
|
|
|
# - the PR is not a draft
|
|
|
|
# - the PR has the "build-image" label
|
|
|
|
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') }}
|
2023-07-18 14:36:12 +03:00
|
|
|
steps:
|
2023-07-18 17:56:42 +03:00
|
|
|
# Repository needs to be cloned so `git rev-parse` below works
|
|
|
|
- name: Clone repository
|
2023-09-11 11:41:26 +03:00
|
|
|
uses: actions/checkout@v4
|
2023-07-18 14:36:12 +03:00
|
|
|
- id: version_vars
|
|
|
|
run: |
|
2023-08-25 19:26:44 +03:00
|
|
|
echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
|
2023-07-18 14:36:12 +03:00
|
|
|
outputs:
|
2023-08-25 19:26:44 +03:00
|
|
|
metadata: ${{ steps.version_vars.outputs.mastodon_version_metadata }}
|
2023-07-18 14:36:12 +03:00
|
|
|
|
|
|
|
build-image:
|
|
|
|
needs: compute-suffix
|
|
|
|
uses: ./.github/workflows/build-container-image.yml
|
|
|
|
with:
|
|
|
|
platforms: linux/amd64,linux/arm64
|
2023-07-19 08:25:59 +03:00
|
|
|
use_native_arm64_builder: false
|
2023-07-18 14:36:12 +03:00
|
|
|
push_to_images: |
|
2023-07-19 08:25:59 +03:00
|
|
|
ghcr.io/${{ github.repository_owner }}/mastodon
|
2023-08-25 19:26:44 +03:00
|
|
|
version_metadata: ${{ needs.compute-suffix.outputs.metadata }}
|
2023-07-18 14:36:12 +03:00
|
|
|
flavor: |
|
|
|
|
latest=auto
|
|
|
|
tags: |
|
|
|
|
type=ref,event=pr
|
|
|
|
secrets: inherit
|