Skip to content

Commit c1602d3

Browse files
committed
try to resolve the ref mismatch for verification
1 parent 3bf664c commit c1602d3

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

.github/workflows/_image-factory.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,39 @@ jobs:
4646
4747
- id: stamp
4848
run: |
49-
CORE="${{ inputs.repo-core-ref || (github.event.client_payload.source_repo == 'mapchete' && github.event.client_payload.sha) || 'main' }}"
50-
EO="${{ inputs.repo-eo-ref || (github.event.client_payload.source_repo == 'mapchete-eo' && github.event.client_payload.sha) || 'main' }}"
51-
HUB="${{ inputs.repo-hub-ref || (github.event.client_payload.source_repo == 'mapchete-hub' && github.event.client_payload.sha) || 'main' }}"
52-
CLI="${{ inputs.repo-cli-ref || (github.event.client_payload.source_repo == 'mapchete-hub-cli' && github.event.client_payload.sha) || 'main' }}"
49+
# Helper function to resolve refs to SHAs
50+
resolve_sha() {
51+
local repo=$1
52+
local ref=$2
53+
if [[ "$ref" =~ ^[0-9a-f]{40}$ ]]; then
54+
echo "$ref" # It's already a SHA
55+
else
56+
# Fetch the SHA for the branch/tag from remote
57+
git ls-remote https://github.com/mapchete/$repo.git "$ref" | awk '{print $1}'
58+
fi
59+
}
60+
61+
# 1. Resolve every input to a real SHA
62+
CORE_REF="${{ inputs.repo-core-ref || (github.event.client_payload.source_repo == 'mapchete' && github.event.client_payload.sha) || 'main' }}"
63+
CORE=$(resolve_sha "mapchete" "$CORE_REF")
64+
65+
EO_REF="${{ inputs.repo-eo-ref || (github.event.client_payload.source_repo == 'mapchete-eo' && github.event.client_payload.sha) || 'main' }}"
66+
EO=$(resolve_sha "mapchete-eo" "$EO_REF")
67+
68+
HUB_REF="${{ inputs.repo-hub-ref || (github.event.client_payload.source_repo == 'mapchete-hub' && github.event.client_payload.sha) || 'main' }}"
69+
HUB=$(resolve_sha "mapchete-hub" "$HUB_REF")
70+
71+
CLI_REF="${{ inputs.repo-cli-ref || (github.event.client_payload.source_repo == 'mapchete-hub-cli' && github.event.client_payload.sha) || 'main' }}"
72+
CLI=$(resolve_sha "mapchete-hub-cli" "$CLI_REF")
5373

74+
# 2. Build context-specific fingerprints using ONLY SHAs
5475
if [[ "${{ inputs.image-name }}" == "mapchete" ]]; then
5576
MANIFEST="${CORE}|${EO}|${HUB}|none"
5677
else
5778
MANIFEST="none|none|${HUB}|${CLI}"
5879
fi
5980

81+
# 3. Export outputs
6082
echo "manifest=$MANIFEST" >> $GITHUB_OUTPUT
6183
echo "core=$CORE" >> $GITHUB_OUTPUT
6284
echo "eo=$EO" >> $GITHUB_OUTPUT

.github/workflows/build-controller.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches: [**]
55
tags: ['[0-9][0-9][0-9][0-9].*']
66
pull_request:
7-
branches: [main]
7+
branches: [**]
88
repository_dispatch:
99
types: [source_update]
1010
workflow_dispatch:

0 commit comments

Comments
 (0)