@@ -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
0 commit comments