ci: push individual arch digest only and merge from digest (#1284)

* ci: push individual arch digest only and merge from digest

* ci: correct syntax for docker manifest

* ci: add the missing id to the build step

* ci: set proper ids and output digest that is dependant on matrix.id

* ci: proper dynamic outputs by manually echoing it out

* ci: remove unnecessary test step
This commit is contained in:
Fallenbagel
2025-01-19 03:41:25 +08:00
committed by GitHub
parent ca739315b2
commit 396cd968ef

View File

@@ -32,17 +32,6 @@ jobs:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-pnpm-store- ${{ runner.os }}-pnpm-store-
- name: Sanitize Owner and Platform name
run: |
echo "OWNER_LC=$(echo '${OWNER}' | tr '[:upper:]' '[:lower:]')" >>${GITHUB_ENV}
echo "PLATFORM=$(echo '${PLATFORM}' | sed 's|/|-|g')" >>${GITHUB_ENV}
env:
OWNER: 'Fallenbagel'
PLATFORM: 'linux/amd64'
- name: Test Sanitized Variables
run: |
echo "Sanitized Owner: $OWNER_LC"
echo "Sanitized Platform: $PLATFORM"
- name: Install dependencies - name: Install dependencies
env: env:
HUSKY: 0 HUSKY: 0
@@ -65,6 +54,9 @@ jobs:
- runner: ubuntu-24.04-arm - runner: ubuntu-24.04-arm
platform: linux/arm64 platform: linux/arm64
runs-on: ${{ matrix.runner }} runs-on: ${{ matrix.runner }}
outputs:
digest-amd64: ${{ steps.set_outputs.outputs.digest-amd64 }}
digest-arm64: ${{ steps.set_outputs.outputs.digest-arm64 }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -86,7 +78,18 @@ jobs:
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env: env:
OWNER: ${{ github.repository_owner }} OWNER: ${{ github.repository_owner }}
- name: Build and push temp platform image - name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
fallenbagel/jellyseerr
ghcr.io/${{ env.OWNER_LC }}/jellyseerr
tags: |
type=ref,event=branch
type=sha,prefix=,suffix=,format=short
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
@@ -95,12 +98,17 @@ jobs:
push: true push: true
build-args: | build-args: |
COMMIT_TAG=${{ github.sha }} COMMIT_TAG=${{ github.sha }}
tags: | outputs: |
fallenbagel/jellyseerr:temp-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} type=image,push-by-digest=true,name=fallenbagel/jellyseerr,push=true
ghcr.io/${{ env.OWNER_LC }}/jellyseerr:temp-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} type=image,push-by-digest=true,name=ghcr.io/${{ env.OWNER_LC }}/jellyseerr,push=true
cache-from: type=gha,scope=${{ matrix.platform }} cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }} cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
provenance: false provenance: false
- name: Set outputs
id: set_outputs
run: |
platform="${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}"
echo "digest-${platform}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
merge_and_push: merge_and_push:
name: Create and Push Multi-arch Manifest name: Create and Push Multi-arch Manifest
@@ -126,14 +134,14 @@ jobs:
- name: Create and push manifest - name: Create and push manifest
run: | run: |
docker manifest create fallenbagel/jellyseerr:develop \ docker manifest create fallenbagel/jellyseerr:develop \
fallenbagel/jellyseerr:temp-amd64 \ --amend fallenbagel/jellyseerr@${{ needs.build.outputs.digest-amd64 }} \
fallenbagel/jellyseerr:temp-arm64 --amend fallenbagel/jellyseerr@${{ needs.build.outputs.digest-arm64 }}
docker manifest push fallenbagel/jellyseerr:develop docker manifest push fallenbagel/jellyseerr:develop
# GHCR manifest # GHCR manifest
docker manifest create ghcr.io/${{ env.OWNER_LC }}/jellyseerr:develop \ docker manifest create ghcr.io/${{ env.OWNER_LC }}/jellyseerr:develop \
ghcr.io/${{ env.OWNER_LC }}/jellyseerr:temp-amd64 \ --amend ghcr.io/${{ env.OWNER_LC }}/jellyseerr@${{ needs.build.outputs.digest-amd64 }} \
ghcr.io/${{ env.OWNER_LC }}/jellyseerr:temp-arm64 --amend ghcr.io/${{ env.OWNER_LC }}/jellyseerr@${{ needs.build.outputs.digest-arm64 }}
docker manifest push ghcr.io/${{ env.OWNER_LC }}/jellyseerr:develop docker manifest push ghcr.io/${{ env.OWNER_LC }}/jellyseerr:develop
discord: discord: