Skip to content

Commit e918ce5

Browse files
committed
On branch edburns/ghcp-sp-122-java-release-improvements
modified: .github/workflows/java-publish-maven.yml - Add a preflight to try to avoid failures.
1 parent 1561552 commit e918ce5

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

.github/workflows/java-publish-maven.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,36 @@ concurrency:
3232
cancel-in-progress: false
3333

3434
jobs:
35+
preflight:
36+
name: Preflight checks
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Verify GITHUB_TOKEN can create releases
40+
run: |
41+
# Test that the token has contents:write by checking repo permissions
42+
PERMS=$(gh api repos/${{ github.repository }} --jq '.permissions.push // false')
43+
if [ "$PERMS" != "true" ]; then
44+
echo "::error::GITHUB_TOKEN lacks push/write permission on this repository. GitHub Release creation will fail."
45+
exit 1
46+
fi
47+
echo "GITHUB_TOKEN permissions OK"
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
51+
- name: Verify JAVA_RELEASE_GITHUB_TOKEN is valid
52+
run: |
53+
# Test that the token can authenticate and trigger workflows
54+
USER=$(gh api user --jq '.login' 2>&1) || {
55+
echo "::error::JAVA_RELEASE_GITHUB_TOKEN is invalid or expired. Changelog trigger will fail."
56+
exit 1
57+
}
58+
echo "JAVA_RELEASE_GITHUB_TOKEN is valid (authenticated as: ${USER})"
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.JAVA_RELEASE_GITHUB_TOKEN }}
61+
3562
publish-maven:
3663
name: Publish Java SDK to Maven Central
64+
needs: preflight
3765
runs-on: ubuntu-latest
3866
defaults:
3967
run:
@@ -177,7 +205,7 @@ jobs:
177205
178206
github-release:
179207
name: Create GitHub Release
180-
needs: publish-maven
208+
needs: [preflight, publish-maven]
181209
if: github.ref == 'refs/heads/main'
182210
runs-on: ubuntu-latest
183211
defaults:

0 commit comments

Comments
 (0)