Skip to content

A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.

Fix github repo stats workflow token setup (#243)

Priyanshu Agrawald44ef7b48b65
diff --git a/.github/workflows/github-repo-stats.yml b/.github/workflows/github-repo-stats.yml
index 6595e16b7..9b35842bb 100644
--- a/.github/workflows/github-repo-stats.yml
+++ b/.github/workflows/github-repo-stats.yml
@@ -17,12 +17,36 @@ jobs:
steps:
- name: generate app token
id: app-token
- uses: actions/create-github-app-token@v1
+ uses: actions/create-github-app-token@v3
with:
app-id: 3189942
private-key: ${{ secrets.POWER_PLATFORM_SKILLS_APP_PRIVATE_KEY }}
permission-administration: read
permission-contents: write
+ permission-metadata: read
+
+ - name: verify traffic API access
+ env:
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ run: |
+ set -euo pipefail
+
+ response_headers="$(mktemp)"
+ trap 'rm -f "${response_headers}"' EXIT
+ status="$(
+ curl -sS -o /dev/null -D "${response_headers}" -w "%{http_code}" \
+ -H "Authorization: Bearer ${GH_TOKEN}" \
+ -H "Accept: application/vnd.github+json" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ "https://api.github.com/repos/${{ github.repository }}/traffic/popular/referrers"
+ )"
+
+ if [ "${status}" != "200" ] && [ "${status}" != "204" ]; then
+ echo "GitHub traffic API preflight failed with HTTP ${status}."
+ echo "The github-repo-stats action needs an installation token with repository Administration: read access."
+ awk 'BEGIN { IGNORECASE = 1 } /^x-accepted-github-permissions:|^x-oauth-scopes:|^x-github-api-version-selected:|^x-ratelimit-/ { print }' "${response_headers}"
+ exit 1
+ fi
- name: run-ghrs
# Use latest release.