From 406a6a5e19e8eaa77e5ed3fe9d58d8625d4adeae Mon Sep 17 00:00:00 2001 From: Jakub Turski Date: Thu, 28 Nov 2024 15:19:01 +0000 Subject: [PATCH] build: simplify rebuild checker --- .github/workflows/maybe-build-yaucore.yaml | 3 +- .github/workflows/maybe-build-yaurora.yaml | 3 +- .github/workflows/maybe-build.yaml | 37 +++++++++++----------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/maybe-build-yaucore.yaml b/.github/workflows/maybe-build-yaucore.yaml index 3904b56..bd5ee69 100644 --- a/.github/workflows/maybe-build-yaucore.yaml +++ b/.github/workflows/maybe-build-yaucore.yaml @@ -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 diff --git a/.github/workflows/maybe-build-yaurora.yaml b/.github/workflows/maybe-build-yaurora.yaml index 7237255..7544345 100644 --- a/.github/workflows/maybe-build-yaurora.yaml +++ b/.github/workflows/maybe-build-yaurora.yaml @@ -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 diff --git a/.github/workflows/maybe-build.yaml b/.github/workflows/maybe-build.yaml index 7120851..0668ccd 100644 --- a/.github/workflows/maybe-build.yaml +++ b/.github/workflows/maybe-build.yaml @@ -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: @@ -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: