diff --git a/.github/resolve-sibling-refs.sh b/.github/resolve-sibling-refs.sh new file mode 100755 index 000000000..08f5db5b9 --- /dev/null +++ b/.github/resolve-sibling-refs.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Resolve which branch of each sibling repo (viperblock, predastore) the CI +# workspace should build against. A cross-repo change is developed on a branch +# of the SAME name in each repo; build against that branch when it exists so the +# set can be tested together, and fall back to dev otherwise. This mirrors the +# resolution the e2e path already does in +# mulga/scripts/tofu-cluster/build-install-artifacts.sh, so unit CI and e2e CI +# agree on how sibling branches are selected. +# +# Reads $BRANCH (the triggering head/ref name) and writes viperblock= and +# predastore= to $GITHUB_OUTPUT for the checkout steps to consume. +set -euo pipefail + +: "${BRANCH:?BRANCH must be set to the triggering branch name}" +: "${GITHUB_OUTPUT:?GITHUB_OUTPUT must be set}" + +for repo in viperblock predastore; do + if git ls-remote --exit-code --heads \ + "https://github.com/mulgadc/${repo}.git" "$BRANCH" >/dev/null 2>&1; then + ref="$BRANCH" + else + ref="dev" + fi + echo "${repo}: building against ${ref}" + echo "${repo}=${ref}" >>"$GITHUB_OUTPUT" +done diff --git a/.github/workflows/spinifex.yml b/.github/workflows/spinifex.yml index be3c9134c..1ff0e7c4b 100644 --- a/.github/workflows/spinifex.yml +++ b/.github/workflows/spinifex.yml @@ -32,18 +32,25 @@ jobs: path: spinifex fetch-depth: 2 + - name: Resolve sibling refs + id: siblings + env: + BRANCH: ${{ github.head_ref || github.ref_name }} + run: bash .github/resolve-sibling-refs.sh + working-directory: spinifex + - name: Checkout Viperblock uses: actions/checkout@v7 with: repository: mulgadc/viperblock - ref: dev + ref: ${{ steps.siblings.outputs.viperblock }} path: viperblock - name: Checkout Predastore uses: actions/checkout@v7 with: repository: mulgadc/predastore - ref: dev + ref: ${{ steps.siblings.outputs.predastore }} path: predastore - name: Setup Go @@ -80,18 +87,25 @@ jobs: with: path: spinifex + - name: Resolve sibling refs + id: siblings + env: + BRANCH: ${{ github.head_ref || github.ref_name }} + run: bash .github/resolve-sibling-refs.sh + working-directory: spinifex + - name: Checkout Viperblock uses: actions/checkout@v7 with: repository: mulgadc/viperblock - ref: dev + ref: ${{ steps.siblings.outputs.viperblock }} path: viperblock - name: Checkout Predastore uses: actions/checkout@v7 with: repository: mulgadc/predastore - ref: dev + ref: ${{ steps.siblings.outputs.predastore }} path: predastore - name: Setup Go @@ -116,18 +130,25 @@ jobs: with: path: spinifex + - name: Resolve sibling refs + id: siblings + env: + BRANCH: ${{ github.head_ref || github.ref_name }} + run: bash .github/resolve-sibling-refs.sh + working-directory: spinifex + - name: Checkout Viperblock uses: actions/checkout@v7 with: repository: mulgadc/viperblock - ref: dev + ref: ${{ steps.siblings.outputs.viperblock }} path: viperblock - name: Checkout Predastore uses: actions/checkout@v7 with: repository: mulgadc/predastore - ref: dev + ref: ${{ steps.siblings.outputs.predastore }} path: predastore - name: Setup Go