Skip to content

Commit

Permalink
build: simplify rebuild checker
Browse files Browse the repository at this point in the history
  • Loading branch information
yacoob committed Nov 28, 2024
1 parent 44e2533 commit 406a6a5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/maybe-build-yaucore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ jobs:
SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }}
uses: ./.github/workflows/maybe-build.yaml
with:
base: ublue-os/ucore-hci:stable
derivative: yacoob/yaucore:latest
image: yacoob/yaucore:latest
recipe: yaucore.yaml
3 changes: 1 addition & 2 deletions .github/workflows/maybe-build-yaurora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ jobs:
SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }}
uses: ./.github/workflows/maybe-build.yaml
with:
base: ublue-os/aurora-dx:stable
derivative: yacoob/yaurora:latest
image: yacoob/yaurora:latest
recipe: yaurora.yaml
37 changes: 19 additions & 18 deletions .github/workflows/maybe-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ name: Check if we need to build a new image due to the base image update
on:
workflow_call:
inputs:
base:
description: Base image (user/name:tag) to check for updates
required: true
type: string
derivative:
description: My image (user/name:tag) to compare against
image:
description: Image (user/name:tag) to check
required: true
type: string
recipe:
description: Recipe file to use for the build
required: true
type: string
secrets:
SIGNING_SECRET:
required: true

jobs:
check:
Expand All @@ -22,29 +21,31 @@ jobs:
outputs:
needs_rebuild: ${{ steps.maybe-build.conclusion == 'success' }}
steps:
- name: Get SHA of the latest ${{ inputs.base }} present in the repository
id: registry
run: |
REGISTRY_SHA=$(skopeo inspect docker://ghcr.io/${{ inputs.base }} | jq '.Digest' )
echo "SHA=$REGISTRY_SHA" >> $GITHUB_OUTPUT
- name: Get SHA of the latest ${{ inputs.derivative }} present in the repository
- name: Get digest of base image that the latest ${{ inputs.image }} was built on
id: last-build
run: |
LAST_BUILD_SHA=$(skopeo inspect docker://ghcr.io/${{ inputs.derivative }} | jq '.Labels."org.opencontainers.image.base.digest"')
LAST_BUILD_SHA=$(skopeo inspect docker://ghcr.io/${{ inputs.image }} | jq '.Labels."org.opencontainers.image.base.digest"')
BASE_IMAGE=$(skopeo inspect docker://ghcr.io/${{ inputs.image }} | jq -r '.Labels."org.opencontainers.image.base.name"')
echo "SHA=$LAST_BUILD_SHA" >> $GITHUB_OUTPUT
echo "BASE_IMAGE=$BASE_IMAGE" >> $GITHUB_OUTPUT
- name: Get SHA of the latest ${{ steps.last-build.outputs.BASE_IMAGE }} available right now
id: latest-base
run: |
SHA=$(skopeo inspect docker://${{ steps.last-build.outputs.BASE_IMAGE }} | jq '.Digest' )
echo "SHA=$SHA" >> $GITHUB_OUTPUT
- name: Output gathered information
id: debug-output
run: |
echo "${{ inputs.base }} is currently at [${{ steps.registry.outputs.SHA }}]"
echo "${{ inputs.derivative }} has last been built at ${{ inputs.base }}'s: [${{ steps.last-build.outputs.SHA }}]"
echo "${{ steps.last-build.outputs.BASE_IMAGE }} is currently at [${{ steps.latest-base.outputs.SHA }}]"
echo "${{ inputs.image }} has last been built at ${{ steps.last-build.outputs.BASE_IMAGE }}'s: [${{ steps.last-build.outputs.SHA }}]"
- name: Decide that we need a new build
id: maybe-build
if: steps.last-build.outputs.SHA != steps.registry.outputs.SHA
if: steps.last-build.outputs.SHA != steps.latest-base.outputs.SHA
run: |
echo "Verdict: ${{ inputs.derivative }} needs to be rebuilt"
echo "Verdict: ${{ inputs.image }} needs to be rebuilt"
build:
permissions:
Expand Down

0 comments on commit 406a6a5

Please sign in to comment.