Skip to content

Commit ce75110

Browse files
authored
fix collateral branch inference logic
1 parent f747bfa commit ce75110

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

‎.github/workflows/build.yml‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,30 @@ jobs:
3535
perl ./list.pl | cut -d/ -f2 | sort > list.pl.out
3636
diff ls.out list.pl.out
3737
38+
dfhack-ref:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
ref: ${{ steps.resolve.outputs.ref }}
42+
steps:
43+
- id: resolve
44+
env:
45+
REPO: ${{ format('{0}/dfhack', github.event_name == 'push' && github.repository_owner || github.event.pull_request.base.repo.owner.login) }}
46+
BRANCH: ${{ github.base_ref || github.ref_name }}
47+
run: |
48+
ref="$BRANCH"
49+
[ "$ref" = master ] && ref=develop
50+
if [ "$ref" != develop ] && ! git ls-remote --exit-code --heads "https://github.com/$REPO" "$ref" >/dev/null 2>&1; then
51+
echo "no '$ref' branch in $REPO; falling back to develop"
52+
ref=develop
53+
fi
54+
echo "ref=$ref" >> "$GITHUB_OUTPUT"
55+
3856
test:
57+
needs: dfhack-ref
3958
uses: DFHack/dfhack/.github/workflows/test.yml@develop
4059
with:
4160
dfhack_repo: ${{ format('{0}/dfhack', github.event_name == 'push' && github.repository_owner || github.event.pull_request.base.repo.owner.login) }}
42-
dfhack_ref: ${{ (((github.base_ref || github.ref_name) == 'master') && 'develop' || (github.base_ref || github.ref_name)) }}
61+
dfhack_ref: ${{ needs.dfhack-ref.outputs.ref }}
4362
structures_repo: ${{ github.repository }}
4463
structures_ref: ${{ github.ref }}
4564
secrets: inherit

0 commit comments

Comments
 (0)