@@ -39,16 +39,59 @@ jobs:
3939 with :
4040 enable-cache : true
4141
42+ - name : Verify token permissions
43+ run : |
44+ echo "Checking token type and permissions..."
45+
46+ # Check token authentication type
47+ AUTH_RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
48+ https://api.github.com/user)
49+ echo "Authenticated as: $(echo $AUTH_RESPONSE | jq -r '.login')"
50+ echo "Account type: $(echo $AUTH_RESPONSE | jq -r '.type')"
51+
52+ # Check repo permissions
53+ RESPONSE=$(curl -s -H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
54+ https://api.github.com/repos/${{ github.repository }})
55+ echo "Permissions: $(echo $RESPONSE | jq -r '.permissions')"
56+
57+ - name : Create monkey-patch script
58+ run : |
59+ cat > /tmp/check_wrapper.py <<'PYEOF'
60+ import sys
61+ from autopub.plugins import github
62+ from autopub.cli import cli
63+
64+ # Monkey-patch to handle 403 errors on forked PRs
65+ original_comment = github.GithubPlugin._update_or_create_comment
66+
67+ def patched_comment(self, text, marker="<!-- autopub-comment -->"):
68+ try:
69+ return original_comment(self, text, marker)
70+ except Exception as e:
71+ error_str = str(e)
72+ if "403" in error_str or "Resource not accessible" in error_str:
73+ print("WARNING: Skipping PR comment due to permission restrictions (forked PR)")
74+ return
75+ raise
76+
77+ github.GithubPlugin._update_or_create_comment = patched_comment
78+
79+ # Run autopub check
80+ sys.exit(cli(["check"], standalone_mode=False) or 0)
81+ PYEOF
82+
4283 - name : Check
4384 id : check
4485 run : |
45- if $AUTOPUB_CMD check; then
86+ uvx --from 'autopub>=1.0.0a51' --with pygithub python3 /tmp/check_wrapper.py
87+
88+ if [ $? -eq 0 ]; then
4689 echo "has_release=true" >> "$GITHUB_OUTPUT"
4790 else
4891 echo "has_release=false" >> "$GITHUB_OUTPUT"
4992 fi
5093 env :
51- GITHUB_TOKEN : ${{ github.token }}
94+ GITHUB_TOKEN : ${{ secrets.BOT_TOKEN }}
5295
5396 - name : Upload .autopub artifact
5497 if : steps.check.outputs.has_release == 'true'
@@ -86,15 +129,15 @@ jobs:
86129
87130 - name : Build and publish
88131 run : |
89- git remote set-url origin https://${{ github.token }}@github.com/${{ github.repository }}
132+ git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }}
90133 echo "✨ Preparing..."
91134 $AUTOPUB_CMD prepare
92135 echo "✨ Building..."
93136 $AUTOPUB_CMD build
94137 echo "✨ Publishing..."
95138 $AUTOPUB_CMD publish
96139 env :
97- GITHUB_TOKEN : ${{ github.token }}
140+ GITHUB_TOKEN : ${{ secrets.BOT_TOKEN }}
98141
99142 - name : Get project version
100143 id : get-version
0 commit comments