Skip to content

Commit 04df03c

Browse files
committed
Switch branch check script to PowerShell in workflow
Replaces the shell script for checking branch existence with a PowerShell script in generation.yml. This improves compatibility with Windows runners and maintains the logic for selecting the target or fallback branch.
1 parent f057800 commit 04df03c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

.github/workflows/generation.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
TARGET_BRANCH: ${{ env.TARGET_BRANCH }}
2323
FALLBACK_BRANCH: ${{ env.FALLBACK_BRANCH }}
2424
run: |
25-
set -euo pipefail
26-
REPO="github.com/${GITHUB_REPOSITORY}"
27-
if git ls-remote --heads "https://x-access-token:${GITHUB_TOKEN}@${REPO}" "${TARGET_BRANCH}" | grep -q "refs/heads/${TARGET_BRANCH}"; then
28-
echo "branch=${TARGET_BRANCH}" >> "$GITHUB_OUTPUT"
29-
else
30-
echo "branch=${FALLBACK_BRANCH}" >> "$GITHUB_OUTPUT"
31-
fi
25+
$REPO = "github.com/$env:GITHUB_REPOSITORY"
26+
$targetBranchExists = git ls-remote --heads "https://x-access-token:$env:GITHUB_TOKEN@$REPO" $env:TARGET_BRANCH
27+
if ($targetBranchExists) {
28+
"branch=$env:TARGET_BRANCH" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
29+
} else {
30+
"branch=$env:FALLBACK_BRANCH" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
31+
}
3232
3333
- name: Checkout main repository
3434
uses: actions/checkout@v4

0 commit comments

Comments
 (0)