Skip to content

Commit 71c67c5

Browse files
committed
refactor: Use PowerShell for token validation and git config
1 parent a3b716f commit 71c67c5

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

updater/action.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,39 +118,40 @@ runs:
118118
Write-Output "✓ Post-update script path '${{ inputs.post-update-script }}' is valid"
119119
120120
- name: Validate GitHub token
121-
shell: bash
121+
shell: pwsh
122122
env:
123123
GH_TOKEN: ${{ inputs.api-token }}
124124
run: |
125-
if [ -z "$GH_TOKEN" ]; then
126-
echo "::error::GitHub token is empty. Please verify the token is passed correctly."
125+
if ([string]::IsNullOrEmpty($env:GH_TOKEN)) {
126+
Write-Output "::error::GitHub token is empty. Please verify the token is passed correctly."
127127
exit 1
128-
fi
128+
}
129129
130-
if echo "$GH_TOKEN" | grep -q '[[:space:]]'; then
131-
echo "::error::GitHub token contains whitespace characters (newlines, spaces, etc). This suggests the token secret may be malformed."
130+
if ($env:GH_TOKEN -match '\s') {
131+
Write-Output "::error::GitHub token contains whitespace characters (newlines, spaces, etc). This suggests the token secret may be malformed."
132132
exit 1
133-
fi
133+
}
134134
135-
if ! gh api repos/${{ github.repository }} --silent 2>&1; then
136-
echo "::error::GitHub token validation failed. Please verify:"
137-
echo " 1. Token is not empty or malformed"
138-
echo " 2. Token has not expired"
139-
echo " 3. Token has an expiration date set"
140-
echo " 4. Token has 'repo' and 'workflow' scopes"
141-
echo " 5. Token syntax is correct: "'${{ secrets.TOKEN_NAME }}'"
135+
gh api repos/${{ github.repository }} --silent 2>&1 | Out-Null
136+
if ($LASTEXITCODE -ne 0) {
137+
Write-Output "::error::GitHub token validation failed. Please verify:"
138+
Write-Output " 1. Token is not empty or malformed"
139+
Write-Output " 2. Token has not expired"
140+
Write-Output " 3. Token has an expiration date set"
141+
Write-Output " 4. Token has 'repo' and 'workflow' scopes"
142+
Write-Output " 5. Token syntax is correct: "'${{ secrets.TOKEN_NAME }}'"
142143
exit 1
143-
fi
144-
echo "✓ GitHub token is valid and has access to this repository"
144+
}
145+
Write-Output "✓ GitHub token is valid and has access to this repository"
145146
146147
- name: Configure git credentials
147-
shell: bash
148+
shell: pwsh
148149
env:
149150
GH_TOKEN: ${{ inputs.api-token }}
150151
run: |
151152
git config --global credential.https://github.com.username git
152-
git config --global credential.https://github.com.password "$GH_TOKEN"
153-
echo "✓ Git credentials configured for GitHub operations"
153+
git config --global credential.https://github.com.password $env:GH_TOKEN
154+
Write-Output "✓ Git credentials configured for GitHub operations"
154155
155156
# What we need to accomplish:
156157
# * update to the latest tag

0 commit comments

Comments
 (0)