Skip to content

Commit 4a29520

Browse files
author
Darius Neațu
committed
Fail fatal if PAT is missing when running on PRs
1 parent 9889e4f commit 4a29520

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/sync-docs.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,25 @@ jobs:
6363
echo "=== Diff ==="
6464
git diff || echo "No changes detected"
6565
66-
- name: Check if PAT is available
66+
- name: Check if PAT is available for PR creation
6767
id: check-pat
6868
run: |
6969
if [ -n "${{ secrets.GH_PAT }}" ]; then
7070
echo "pat_available=true" >> $GITHUB_OUTPUT
7171
echo "✅ GH_PAT secret is available - will use it for PR creation"
7272
else
7373
echo "pat_available=false" >> $GITHUB_OUTPUT
74-
echo "⚠️ GH_PAT secret not found - using GITHUB_TOKEN (limited permissions on PRs)"
74+
if [ "${{ github.event_name }}" == "pull_request" ]; then
75+
echo "❌ FATAL: GH_PAT secret is required when running on pull_request events"
76+
echo " Add GH_PAT secret at: Settings > Secrets and variables > Actions"
77+
exit 1
78+
else
79+
echo "⚠️ GH_PAT secret not found - using GITHUB_TOKEN"
80+
fi
7581
fi
7682
7783
- name: Create Pull Request
78-
if: github.event_name != 'pull_request'
84+
if: github.event_name != 'pull_request' || steps.check-pat.outputs.pat_available == 'true'
7985
uses: peter-evans/create-pull-request@v6
8086
with:
8187
token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)