File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 9898 exit 1
9999 fi
100100
101- echo "✓ PAT is valid and has access to ${{ env.TARGET_REPO }}"
101+ echo "✓ PAT is valid and has read access to ${{ env.TARGET_REPO }}"
102+
103+ # Check if PAT has write (push) permissions by checking the permissions field
104+ PUSH_PERMISSION=$(cat /tmp/gh_response.json | jq -r '.permissions.push // false')
105+ if [ "$PUSH_PERMISSION" != "true" ]; then
106+ echo ""
107+ echo "=========================================="
108+ echo "❌ ERROR: DEMO_REPO_PAT LACKS WRITE ACCESS"
109+ echo "=========================================="
110+ echo ""
111+ echo "The PAT can read ${{ env.TARGET_REPO }} but cannot push to it."
112+ echo ""
113+ echo "This can happen if:"
114+ echo " 1. The PAT is a fine-grained token without 'Contents: Read and write' permission"
115+ echo " 2. The PAT is a classic token without 'repo' scope"
116+ echo " 3. The repository has branch protection rules blocking the PAT"
117+ echo ""
118+ echo "To fix this:"
119+ echo " - For fine-grained PATs: Ensure 'Contents' permission is set to 'Read and write'"
120+ echo " - For classic PATs: Ensure 'repo' scope is enabled"
121+ echo " - Update the secret at: https://github.com/${{ github.repository }}/settings/secrets/actions"
122+ echo ""
123+ exit 1
124+ fi
125+
126+ echo "✓ PAT has write access to ${{ env.TARGET_REPO }}"
102127
103128 - name : Checkout source repository
104129 if : env.secret_configured == 'true'
You can’t perform that action at this time.
0 commit comments