|
| 1 | +- name: Debug GitHub Actions Environment |
| 2 | + run: | |
| 3 | + echo "### 🔍 Checking GitHub Secrets & Environment Variables ###" |
| 4 | +
|
| 5 | + # Check if GITHUB_TOKEN is set |
| 6 | + if [[ -z "${{ secrets.GITHUB_TOKEN }}" ]]; then |
| 7 | + echo "❌ GITHUB_TOKEN is NOT set. This may be due to missing permissions or a misconfigured repository secret."; |
| 8 | + else |
| 9 | + echo "✅ GITHUB_TOKEN is set."; |
| 10 | + fi |
| 11 | +
|
| 12 | + # Check if NPM_TOKEN is set |
| 13 | + if [[ -z "${{ secrets.NPM_TOKEN }}" ]]; then |
| 14 | + echo "❌ NPM_TOKEN is NOT set. Ensure it exists in repository secrets under Settings → Secrets."; |
| 15 | + else |
| 16 | + echo "✅ NPM_TOKEN is set."; |
| 17 | + fi |
| 18 | +
|
| 19 | + # Check if the GitHub token from the context is available |
| 20 | + if [[ -z "${{ github.token }}" ]]; then |
| 21 | + echo "❌ github.token is NOT set. This is unusual since it's auto-generated by GitHub."; |
| 22 | + else |
| 23 | + echo "✅ github.token is available."; |
| 24 | + fi |
| 25 | +
|
| 26 | + # Check current GitHub Actions permissions |
| 27 | + echo "🔹 Workflow permissions setting:" |
| 28 | + curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 29 | + -H "Accept: application/vnd.github.v3+json" \ |
| 30 | + https://api.github.com/repos/${{ github.repository }} \ |
| 31 | + | jq '.permissions' |
| 32 | +
|
| 33 | + # Check if running from a forked repo (which can block secrets) |
| 34 | + if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then |
| 35 | + echo "⚠️ This workflow is running from a fork. GitHub restricts repository secrets for forks."; |
| 36 | + else |
| 37 | + echo "✅ This workflow is running in the original repository."; |
| 38 | + fi |
| 39 | +
|
| 40 | + # Check if environment variables are set |
| 41 | + echo "🔹 Checking system environment variables:" |
| 42 | + env | grep -E 'GITHUB|NPM' || echo "⚠️ No GITHUB/NPM environment variables found." |
0 commit comments