2023-07-18 20:36:12 +09: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 23:56:42 +09: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 20:36:12 +09:00
|
|
|
steps:
|
2023-07-18 23:56:42 +09:00
|
|
|
# Repository needs to be cloned so `git rev-parse` below works
|
|
|
|
- name: Clone repository
|
2023-09-11 17:41:26 +09:00
|
|
|
uses: actions/checkout@v4
|
2023-07-18 20:36:12 +09:00
|
|
|
- id: version_vars
|
|
|
|
run: |
|
2024-10-11 23:16:37 +09:00
|
|
|
echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short ${{github.event.pull_request.head.sha}}) >> $GITHUB_OUTPUT
|
|
|
|
echo mastodon_short_sha=$(git rev-parse --short ${{github.event.pull_request.head.sha}}) >> $GITHUB_OUTPUT
|
2023-07-18 20:36:12 +09:00
|
|
|
outputs:
|
2023-08-26 01:26:44 +09:00
|
|
|
metadata: ${{ steps.version_vars.outputs.mastodon_version_metadata }}
|
2024-10-11 23:16:37 +09:00
|
|
|
short_sha: ${{ steps.version_vars.outputs.mastodon_short_sha }}
|
2023-07-18 20:36:12 +09:00
|
|
|
|
|
|
|
build-image:
|
|
|
|
needs: compute-suffix
|
|
|
|
uses: ./.github/workflows/build-container-image.yml
|
|
|
|
with:
|
2023-11-28 19:04:40 +09:00
|
|
|
file_to_build: Dockerfile
|
2023-07-18 20:36:12 +09:00
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
use_native_arm64_builder: true
|
|
|
|
push_to_images: |
|
|
|
|
ghcr.io/mastodon/mastodon
|
2023-08-26 01:26:44 +09:00
|
|
|
version_metadata: ${{ needs.compute-suffix.outputs.metadata }}
|
2023-07-18 20:36:12 +09:00
|
|
|
flavor: |
|
|
|
|
latest=auto
|
|
|
|
tags: |
|
|
|
|
type=ref,event=pr
|
2024-10-11 23:16:37 +09:00
|
|
|
type=ref,event=pr,suffix=-${{ needs.compute-suffix.outputs.short_sha }}
|
2023-07-18 20:36:12 +09:00
|
|
|
secrets: inherit
|
2023-11-28 19:04:40 +09:00
|
|
|
|
|
|
|
build-image-streaming:
|
|
|
|
needs: compute-suffix
|
|
|
|
uses: ./.github/workflows/build-container-image.yml
|
|
|
|
with:
|
|
|
|
file_to_build: streaming/Dockerfile
|
|
|
|
platforms: linux/amd64,linux/arm64
|
|
|
|
use_native_arm64_builder: true
|
|
|
|
push_to_images: |
|
|
|
|
ghcr.io/mastodon/mastodon-streaming
|
|
|
|
version_metadata: ${{ needs.compute-suffix.outputs.metadata }}
|
|
|
|
flavor: |
|
|
|
|
latest=auto
|
|
|
|
tags: |
|
|
|
|
type=ref,event=pr
|
2024-10-11 23:16:37 +09:00
|
|
|
type=ref,event=pr,suffix=-${{ needs.compute-suffix.outputs.short_sha }}
|
2023-11-28 19:04:40 +09:00
|
|
|
secrets: inherit
|