From 0f849eefa700f5b34ac867dd1d700b095dc37c27 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 15:40:50 +0000 Subject: [PATCH 1/4] Initial plan for issue From 92bdc71966923c6c1a1ec865244173443431874f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 15:43:13 +0000 Subject: [PATCH 2/4] Update GitHub workflow to use custom token Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> --- .github/README.md | 29 +++++++++++++++++++ .github/workflows/add-files-changed-label.yml | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 .github/README.md diff --git a/.github/README.md b/.github/README.md new file mode 100644 index 0000000000..6e30ce0085 --- /dev/null +++ b/.github/README.md @@ -0,0 +1,29 @@ +# GitHub Actions Configuration + +This directory contains GitHub Actions workflows and configuration files used in the BLT project. + +## GitHub Token Permissions + +Some workflows may require additional permissions beyond what the default `GITHUB_TOKEN` provides. For workflows that need to modify issues, pull requests, or add labels, a custom Personal Access Token (PAT) may be needed. + +### Setting up a Custom GitHub Token + +For workflows that require higher permissions (like the "Add Files Changed Label" workflow), follow these steps: + +1. Create a new Personal Access Token (PAT) with the appropriate permissions: + - Go to your GitHub account Settings > Developer settings > Personal access tokens > Tokens (classic) + - Generate a new token with the following permissions: + - `repo` - Full control of private repositories + - `workflow` - Update GitHub Action workflows + - Copy the generated token + +2. Add the token as a repository secret: + - Go to your repository settings > Secrets and variables > Actions + - Create a new repository secret named `CUSTOM_GITHUB_TOKEN` + - Paste the token value you copied + +### Workflows that use custom tokens + +The following workflows can leverage the custom token for enhanced permissions: + +- **add-files-changed-label.yml**: Adds labels to PRs based on the number of files changed \ No newline at end of file diff --git a/.github/workflows/add-files-changed-label.yml b/.github/workflows/add-files-changed-label.yml index 2e5fe64275..bb87132639 100644 --- a/.github/workflows/add-files-changed-label.yml +++ b/.github/workflows/add-files-changed-label.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Add Files Changed Label env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} REPO_OWNER: ${{ github.repository_owner }} REPO_NAME: ${{ github.event.repository.name }} From 9ee9578ba435d2c065cd76c95dd9194eed1e2356 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 May 2025 15:43:48 +0000 Subject: [PATCH 3/4] Improve error handling in GitHub workflow Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> --- .github/workflows/add-files-changed-label.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-files-changed-label.yml b/.github/workflows/add-files-changed-label.yml index bb87132639..165b37d850 100644 --- a/.github/workflows/add-files-changed-label.yml +++ b/.github/workflows/add-files-changed-label.yml @@ -33,8 +33,8 @@ jobs: "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/files") # Check if the API request was successful - if [[ "$FILES_API_RESPONSE" == *"message"*"Not Found"* ]]; then - echo "Error: Could not fetch PR files. API response indicates resource not found." + if [[ "$FILES_API_RESPONSE" == *"message"*"Not Found"* ]] || [[ "$FILES_API_RESPONSE" == *"Resource not accessible by integration"* ]]; then + echo "Error: Could not fetch PR files. Response: $FILES_API_RESPONSE" exit 1 fi @@ -141,6 +141,13 @@ jobs: # Check if label was added successfully if [[ "$ADD_LABEL_RESPONSE" == *"message"* ]]; then echo "Error: Failed to add label. Response: $ADD_LABEL_RESPONSE" + + # Check if it's a permissions issue and suggest using a custom token + if [[ "$ADD_LABEL_RESPONSE" == *"Resource not accessible by integration"* ]]; then + echo "This appears to be a permissions issue. Please configure a CUSTOM_GITHUB_TOKEN secret with higher permissions." + echo "See the .github/README.md file for instructions on setting up the token." + fi + exit 1 else echo "Successfully applied label '$LABEL' to PR #$PR_NUMBER" From c8d72907e3c4211f7eb36485e191baaa440711ef Mon Sep 17 00:00:00 2001 From: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com> Date: Thu, 22 May 2025 09:19:29 -0400 Subject: [PATCH 4/4] Delete .github/README.md --- .github/README.md | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/README.md diff --git a/.github/README.md b/.github/README.md deleted file mode 100644 index 6e30ce0085..0000000000 --- a/.github/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# GitHub Actions Configuration - -This directory contains GitHub Actions workflows and configuration files used in the BLT project. - -## GitHub Token Permissions - -Some workflows may require additional permissions beyond what the default `GITHUB_TOKEN` provides. For workflows that need to modify issues, pull requests, or add labels, a custom Personal Access Token (PAT) may be needed. - -### Setting up a Custom GitHub Token - -For workflows that require higher permissions (like the "Add Files Changed Label" workflow), follow these steps: - -1. Create a new Personal Access Token (PAT) with the appropriate permissions: - - Go to your GitHub account Settings > Developer settings > Personal access tokens > Tokens (classic) - - Generate a new token with the following permissions: - - `repo` - Full control of private repositories - - `workflow` - Update GitHub Action workflows - - Copy the generated token - -2. Add the token as a repository secret: - - Go to your repository settings > Secrets and variables > Actions - - Create a new repository secret named `CUSTOM_GITHUB_TOKEN` - - Paste the token value you copied - -### Workflows that use custom tokens - -The following workflows can leverage the custom token for enhanced permissions: - -- **add-files-changed-label.yml**: Adds labels to PRs based on the number of files changed \ No newline at end of file