From 7d656c4457a8fb2c0fc73c8879782593806ad7b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:34:13 +0000 Subject: [PATCH 1/7] Initial plan From 332f4895fbf0db6bc6874e6ffd28200b67bab003 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:39:47 +0000 Subject: [PATCH 2/7] Initial plan for create-pull-request error handling Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../templates/upgrade-agentic-workflows.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/cli/templates/upgrade-agentic-workflows.md b/pkg/cli/templates/upgrade-agentic-workflows.md index b05cb67671..b278e47797 100644 --- a/pkg/cli/templates/upgrade-agentic-workflows.md +++ b/pkg/cli/templates/upgrade-agentic-workflows.md @@ -23,15 +23,16 @@ Read the ENTIRE content of this file carefully before proceeding. Follow the ins - `compile` → compile all workflows - `compile ` → compile a specific workflow -:::note[Command Execution] -When running in GitHub Copilot Cloud, you don't have direct access to `gh aw` CLI commands. Instead, use the **agentic-workflows** MCP tool: -- `fix` tool → apply automatic codemods to fix deprecated fields -- `compile` tool → compile workflows - -When running in other environments with `gh aw` CLI access, prefix commands with `gh aw` (e.g., `gh aw compile`). - -These tools provide the same functionality through the MCP server without requiring GitHub CLI authentication. -::: +> [!NOTE] +> **Command Execution** +> +> When running in GitHub Copilot Cloud, you don't have direct access to `gh aw` CLI commands. Instead, use the **agentic-workflows** MCP tool: +> - `fix` tool → apply automatic codemods to fix deprecated fields +> - `compile` tool → compile workflows +> +> When running in other environments with `gh aw` CLI access, prefix commands with `gh aw` (e.g., `gh aw compile`). +> +> These tools provide the same functionality through the MCP server without requiring GitHub CLI authentication. ## Instructions From 139b73b17389ec5f11f0acc0ca743efaa84ab394 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:43:30 +0000 Subject: [PATCH 3/7] Add error handling for create-pull-request permission error - Modified create_pull_request.cjs to detect "GitHub Actions is not permitted to create or approve pull requests" error - Set error_message output variable when permission error occurs - Added error_message output to create_pull_request job definition - Added conclusion job step to handle permission errors and create tracking issue - Issue includes instructions and documentation link for enabling PR creation permission Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- actions/setup/js/create_pull_request.cjs | 23 +++++- pkg/workflow/create_pull_request.go | 1 + pkg/workflow/notify_comment.go | 89 ++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 3 deletions(-) diff --git a/actions/setup/js/create_pull_request.cjs b/actions/setup/js/create_pull_request.cjs index 9b550ac985..75df588457 100644 --- a/actions/setup/js/create_pull_request.cjs +++ b/actions/setup/js/create_pull_request.cjs @@ -705,7 +705,24 @@ ${patchPreview}`; repo: itemRepo, }; } catch (prError) { - core.warning(`Failed to create pull request: ${prError instanceof Error ? prError.message : String(prError)}`); + const errorMessage = prError instanceof Error ? prError.message : String(prError); + core.warning(`Failed to create pull request: ${errorMessage}`); + + // Check if the error is the specific "GitHub actions is not permitted to create or approve pull requests" error + if (errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.error("Permission error: GitHub Actions is not permitted to create or approve pull requests"); + // Set output variable for conclusion job to handle + core.setOutput( + "error_message", + "GitHub Actions is not permitted to create or approve pull requests. Please enable 'Allow GitHub Actions to create and approve pull requests' in repository settings: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests" + ); + return { + success: false, + error: errorMessage, + error_type: "permission_denied", + }; + } + core.info("Falling back to creating an issue instead"); // Create issue as fallback with enhanced body content @@ -725,7 +742,7 @@ ${patchPreview}`; **Note:** This was originally intended as a pull request, but PR creation failed. The changes have been pushed to the branch [\`${branchName}\`](${branchUrl}). -**Original error:** ${prError instanceof Error ? prError.message : String(prError)} +**Original error:** ${errorMessage} You can manually create a pull request from the branch if needed.${patchPreview}`; @@ -753,7 +770,7 @@ You can manually create a pull request from the branch if needed.${patchPreview} repo: itemRepo, }; } catch (issueError) { - const error = `Failed to create both pull request and fallback issue. PR error: ${prError instanceof Error ? prError.message : String(prError)}. Issue error: ${issueError instanceof Error ? issueError.message : String(issueError)}`; + const error = `Failed to create both pull request and fallback issue. PR error: ${errorMessage}. Issue error: ${issueError instanceof Error ? issueError.message : String(issueError)}`; core.error(error); return { success: false, diff --git a/pkg/workflow/create_pull_request.go b/pkg/workflow/create_pull_request.go index 184989f46a..45f2151e7a 100644 --- a/pkg/workflow/create_pull_request.go +++ b/pkg/workflow/create_pull_request.go @@ -136,6 +136,7 @@ func (c *Compiler) buildCreateOutputPullRequestJob(data *WorkflowData, mainJobNa "issue_url": "${{ steps.create_pull_request.outputs.issue_url }}", "branch_name": "${{ steps.create_pull_request.outputs.branch_name }}", "fallback_used": "${{ steps.create_pull_request.outputs.fallback_used }}", + "error_message": "${{ steps.create_pull_request.outputs.error_message }}", } // Use the shared builder function to create the job diff --git a/pkg/workflow/notify_comment.go b/pkg/workflow/notify_comment.go index 52b07ed2cb..079cfb3ad6 100644 --- a/pkg/workflow/notify_comment.go +++ b/pkg/workflow/notify_comment.go @@ -180,6 +180,95 @@ func (c *Compiler) buildConclusionJob(data *WorkflowData, mainJobName string, sa }) steps = append(steps, agentFailureSteps...) + // Add create_pull_request error handling step if create-pull-request is configured + if data.SafeOutputs != nil && data.SafeOutputs.CreatePullRequests != nil { + // Build environment variables for the create PR error handler + var createPRErrorEnvVars []string + createPRErrorEnvVars = append(createPRErrorEnvVars, " CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }}\n") + createPRErrorEnvVars = append(createPRErrorEnvVars, buildWorkflowMetadataEnvVarsWithTrackerID(data.Name, data.Source, data.TrackerID)...) + createPRErrorEnvVars = append(createPRErrorEnvVars, " GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n") + + // Build the create PR error handling step + createPRErrorSteps := c.buildGitHubScriptStepWithoutDownload(data, GitHubScriptStepConfig{ + StepName: "Handle Create Pull Request Error", + StepID: "handle_create_pr_error", + MainJobName: mainJobName, + CustomEnvVars: createPRErrorEnvVars, + Script: ` + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + + // Check if this is the permission error + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + + core.info("Creating issue for create_pull_request permission error"); + + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + + // Search for existing issue with the same title + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + + // Add a comment with run details + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + // Create new issue + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } + `, + ScriptFile: "handle_create_pr_error.cjs", + Token: "", // Will use default GITHUB_TOKEN + }) + steps = append(steps, createPRErrorSteps...) + } + // Build environment variables for the conclusion script var customEnvVars []string customEnvVars = append(customEnvVars, fmt.Sprintf(" GH_AW_COMMENT_ID: ${{ needs.%s.outputs.comment_id }}\n", constants.ActivationJobName)) From 026b1d9a1c0ed731981450ab02d0e18e651ef71e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:54:32 +0000 Subject: [PATCH 4/7] Fix inline script for create PR error handling - Changed from file-based script to inline script in notify_comment.go - Script is now properly embedded in the conclusion job step - All unit tests related to my changes pass - Note: Unrelated TestCodexEngineRenderMCPConfig failure exists in main Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/ci-coach.lock.yml | 67 ++++++++ .github/workflows/cloclo.lock.yml | 66 ++++++++ .../workflows/code-scanning-fixer.lock.yml | 66 ++++++++ .github/workflows/code-simplifier.lock.yml | 67 ++++++++ .github/workflows/daily-doc-updater.lock.yml | 67 ++++++++ .../workflows/daily-workflow-updater.lock.yml | 67 ++++++++ .github/workflows/dependabot-bundler.lock.yml | 66 ++++++++ .../developer-docs-consolidator.lock.yml | 66 ++++++++ .github/workflows/dictation-prompt.lock.yml | 66 ++++++++ .../github-mcp-tools-report.lock.yml | 66 ++++++++ .../workflows/glossary-maintainer.lock.yml | 66 ++++++++ .github/workflows/go-logger.lock.yml | 66 ++++++++ .github/workflows/hourly-ci-cleaner.lock.yml | 67 ++++++++ .../workflows/instructions-janitor.lock.yml | 66 ++++++++ .github/workflows/jsweep.lock.yml | 67 ++++++++ .../workflows/layout-spec-maintainer.lock.yml | 67 ++++++++ .github/workflows/poem-bot.lock.yml | 66 ++++++++ .github/workflows/q.lock.yml | 66 ++++++++ .../workflows/secret-scanning-triage.lock.yml | 66 ++++++++ .../workflows/slide-deck-maintainer.lock.yml | 67 ++++++++ .../workflows/technical-doc-writer.lock.yml | 66 ++++++++ .../test-create-pr-error-handling.lock.yml | 66 ++++++++ .github/workflows/tidy.lock.yml | 66 ++++++++ .../workflows/ubuntu-image-analyzer.lock.yml | 67 ++++++++ .github/workflows/unbloat-docs.lock.yml | 66 ++++++++ pkg/workflow/notify_comment.go | 145 +++++++++--------- 26 files changed, 1733 insertions(+), 71 deletions(-) diff --git a/.github/workflows/ci-coach.lock.yml b/.github/workflows/ci-coach.lock.yml index db9e08ce15..d6cf3e62ce 100644 --- a/.github/workflows/ci-coach.lock.yml +++ b/.github/workflows/ci-coach.lock.yml @@ -1612,6 +1612,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "CI Optimization Coach" + GH_AW_TRACKER_ID: "ci-coach-daily" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/cloclo.lock.yml b/.github/workflows/cloclo.lock.yml index bf58efd4e0..cc8cdcfd5c 100644 --- a/.github/workflows/cloclo.lock.yml +++ b/.github/workflows/cloclo.lock.yml @@ -1393,6 +1393,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "/cloclo" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/code-scanning-fixer.lock.yml b/.github/workflows/code-scanning-fixer.lock.yml index a8ebc39069..29c30c64ca 100644 --- a/.github/workflows/code-scanning-fixer.lock.yml +++ b/.github/workflows/code-scanning-fixer.lock.yml @@ -1100,6 +1100,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Code Scanning Fixer" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/code-simplifier.lock.yml b/.github/workflows/code-simplifier.lock.yml index 420aab3450..0accb0871f 100644 --- a/.github/workflows/code-simplifier.lock.yml +++ b/.github/workflows/code-simplifier.lock.yml @@ -1252,6 +1252,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Code Simplifier" + GH_AW_TRACKER_ID: "code-simplifier" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index e4609eceba..ba41486c90 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -1109,6 +1109,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Daily Documentation Updater" + GH_AW_TRACKER_ID: "daily-doc-updater" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/daily-workflow-updater.lock.yml b/.github/workflows/daily-workflow-updater.lock.yml index 53a5cdddf8..e8835aed0b 100644 --- a/.github/workflows/daily-workflow-updater.lock.yml +++ b/.github/workflows/daily-workflow-updater.lock.yml @@ -1013,6 +1013,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Daily Workflow Updater" + GH_AW_TRACKER_ID: "daily-workflow-updater" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/dependabot-bundler.lock.yml b/.github/workflows/dependabot-bundler.lock.yml index 35ccc2622b..191955e8e1 100644 --- a/.github/workflows/dependabot-bundler.lock.yml +++ b/.github/workflows/dependabot-bundler.lock.yml @@ -1002,6 +1002,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Dependabot Bundler" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index afab029564..40f6d978da 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -1657,6 +1657,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Developer Documentation Consolidator" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/dictation-prompt.lock.yml b/.github/workflows/dictation-prompt.lock.yml index f540e3e67d..9c25caf72c 100644 --- a/.github/workflows/dictation-prompt.lock.yml +++ b/.github/workflows/dictation-prompt.lock.yml @@ -975,6 +975,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Dictation Prompt Generator" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index af01e21219..3884a134fd 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -1504,6 +1504,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "GitHub MCP Remote Server Tools Report Generator" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/glossary-maintainer.lock.yml b/.github/workflows/glossary-maintainer.lock.yml index 3dc6a99b4f..029f9dac1c 100644 --- a/.github/workflows/glossary-maintainer.lock.yml +++ b/.github/workflows/glossary-maintainer.lock.yml @@ -1644,6 +1644,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Glossary Maintainer" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/go-logger.lock.yml b/.github/workflows/go-logger.lock.yml index ef13bfc048..6f431a4e36 100644 --- a/.github/workflows/go-logger.lock.yml +++ b/.github/workflows/go-logger.lock.yml @@ -1218,6 +1218,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Go Logger Enhancement" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/hourly-ci-cleaner.lock.yml b/.github/workflows/hourly-ci-cleaner.lock.yml index 8cc89c4cb0..0c0831db2a 100644 --- a/.github/workflows/hourly-ci-cleaner.lock.yml +++ b/.github/workflows/hourly-ci-cleaner.lock.yml @@ -1245,6 +1245,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "CI Cleaner" + GH_AW_TRACKER_ID: "hourly-ci-cleaner" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/instructions-janitor.lock.yml b/.github/workflows/instructions-janitor.lock.yml index 88d10aef2a..71992009fe 100644 --- a/.github/workflows/instructions-janitor.lock.yml +++ b/.github/workflows/instructions-janitor.lock.yml @@ -1098,6 +1098,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Instructions Janitor" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/jsweep.lock.yml b/.github/workflows/jsweep.lock.yml index 92c68274e8..aeb0238044 100644 --- a/.github/workflows/jsweep.lock.yml +++ b/.github/workflows/jsweep.lock.yml @@ -1129,6 +1129,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "jsweep - JavaScript Unbloater" + GH_AW_TRACKER_ID: "jsweep-daily" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/layout-spec-maintainer.lock.yml b/.github/workflows/layout-spec-maintainer.lock.yml index 6201520160..f81e48d72c 100644 --- a/.github/workflows/layout-spec-maintainer.lock.yml +++ b/.github/workflows/layout-spec-maintainer.lock.yml @@ -1134,6 +1134,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Layout Specification Maintainer" + GH_AW_TRACKER_ID: "layout-spec-maintainer" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index 8ffe72eada..f50523df17 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -1588,6 +1588,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Poem Bot - A Creative Agentic Workflow" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index 1b139b0962..cfb5b0f731 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -1382,6 +1382,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Q" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/secret-scanning-triage.lock.yml b/.github/workflows/secret-scanning-triage.lock.yml index 1b98295776..47caab0dd3 100644 --- a/.github/workflows/secret-scanning-triage.lock.yml +++ b/.github/workflows/secret-scanning-triage.lock.yml @@ -1066,6 +1066,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Secret Scanning Triage" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/slide-deck-maintainer.lock.yml b/.github/workflows/slide-deck-maintainer.lock.yml index 4c07551347..067e07c7e0 100644 --- a/.github/workflows/slide-deck-maintainer.lock.yml +++ b/.github/workflows/slide-deck-maintainer.lock.yml @@ -1144,6 +1144,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Slide Deck Maintainer" + GH_AW_TRACKER_ID: "slide-deck-maintainer" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index d1f7e1c673..6b06c63a39 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -1546,6 +1546,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Rebuild the documentation after making changes" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/test-create-pr-error-handling.lock.yml b/.github/workflows/test-create-pr-error-handling.lock.yml index 084da65b52..25f1e76951 100644 --- a/.github/workflows/test-create-pr-error-handling.lock.yml +++ b/.github/workflows/test-create-pr-error-handling.lock.yml @@ -935,6 +935,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Test Create PR Error Handling" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index ceb787be77..a97307fff9 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -1027,6 +1027,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Tidy" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/ubuntu-image-analyzer.lock.yml b/.github/workflows/ubuntu-image-analyzer.lock.yml index 53c290d675..5206338e3d 100644 --- a/.github/workflows/ubuntu-image-analyzer.lock.yml +++ b/.github/workflows/ubuntu-image-analyzer.lock.yml @@ -1302,6 +1302,73 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Ubuntu Actions Image Analyzer" + GH_AW_TRACKER_ID: "ubuntu-image-analyzer" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index bdbd910d0c..d124d0758b 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -1506,6 +1506,72 @@ jobs: setupGlobals(core, github, context, exec, io); const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs'); await main(); + - name: Handle Create Pull Request Error + id: handle_create_pr_error + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }} + CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }} + GH_AW_WORKFLOW_NAME: "Documentation Unbloat" + GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + core.info("Creating issue for create_pull_request permission error"); + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/pkg/workflow/notify_comment.go b/pkg/workflow/notify_comment.go index 079cfb3ad6..882dc94050 100644 --- a/pkg/workflow/notify_comment.go +++ b/pkg/workflow/notify_comment.go @@ -188,83 +188,86 @@ func (c *Compiler) buildConclusionJob(data *WorkflowData, mainJobName string, sa createPRErrorEnvVars = append(createPRErrorEnvVars, buildWorkflowMetadataEnvVarsWithTrackerID(data.Name, data.Source, data.TrackerID)...) createPRErrorEnvVars = append(createPRErrorEnvVars, " GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n") + // Inline script for handling create PR errors + createPRErrorScript := ` +const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; +if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; +} + +// Check if this is the permission error +if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; +} + +core.info("Creating issue for create_pull_request permission error"); + +const { owner, repo } = context.repo; +const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; +const runUrl = process.env.GH_AW_RUN_URL || ""; +const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; +const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + +const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + +const issueBody = "## GitHub Actions Permission Required\n\n" + + "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + workflowName + "\n" + + "- **Run**: " + runUrl + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; + +// Search for existing issue with the same title +const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; +const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, +}); + +if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + + // Add a comment with run details + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); +} else { + // Create new issue + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); +} +` + // Build the create PR error handling step createPRErrorSteps := c.buildGitHubScriptStepWithoutDownload(data, GitHubScriptStepConfig{ StepName: "Handle Create Pull Request Error", StepID: "handle_create_pr_error", MainJobName: mainJobName, CustomEnvVars: createPRErrorEnvVars, - Script: ` - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - - // Check if this is the permission error - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - - core.info("Creating issue for create_pull_request permission error"); - - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - - // Search for existing issue with the same title - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - - // Add a comment with run details - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - // Create new issue - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } - `, - ScriptFile: "handle_create_pr_error.cjs", - Token: "", // Will use default GITHUB_TOKEN + Script: createPRErrorScript, + ScriptFile: "", // Inline script, no file + Token: "", // Will use default GITHUB_TOKEN }) steps = append(steps, createPRErrorSteps...) } From d5525fe439841536c07f0f2fb3b54ccdc7316778 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 01:38:37 +0000 Subject: [PATCH 5/7] Move JavaScript to separate file and use require pattern - Created handle_create_pr_error.cjs in actions/setup/js/ - Updated notify_comment.go to use require() instead of inline script - Script is automatically copied by setup.sh to /opt/gh-aw/actions/ - Follows same pattern as other handlers like handle_agent_failure.cjs Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .../test-create-pr-error-handling.lock.yml | 59 +------------ actions/setup/js/handle_create_pr_error.cjs | 88 +++++++++++++++++++ pkg/workflow/notify_comment.go | 75 +--------------- 3 files changed, 94 insertions(+), 128 deletions(-) create mode 100644 actions/setup/js/handle_create_pr_error.cjs diff --git a/.github/workflows/test-create-pr-error-handling.lock.yml b/.github/workflows/test-create-pr-error-handling.lock.yml index 25f1e76951..c226e5f584 100644 --- a/.github/workflows/test-create-pr-error-handling.lock.yml +++ b/.github/workflows/test-create-pr-error-handling.lock.yml @@ -946,61 +946,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/actions/setup/js/handle_create_pr_error.cjs b/actions/setup/js/handle_create_pr_error.cjs new file mode 100644 index 0000000000..aef37df5fb --- /dev/null +++ b/actions/setup/js/handle_create_pr_error.cjs @@ -0,0 +1,88 @@ +// @ts-check +/// + +/** + * Handle create_pull_request permission errors + * This script is called from the conclusion job when create_pull_request fails + * due to GitHub Actions not being permitted to create or approve pull requests. + */ + +async function main() { + const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; + if (!errorMessage) { + core.info("No create_pull_request error message - skipping"); + return; + } + + // Check if this is the permission error + if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { + core.info("Not a permission error - skipping"); + return; + } + + core.info("Creating issue for create_pull_request permission error"); + + const { owner, repo } = context.repo; + const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; + const runUrl = process.env.GH_AW_RUN_URL || ""; + const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; + const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; + + const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; + + const issueBody = + "## GitHub Actions Permission Required\n\n" + + "The workflow **" + + workflowName + + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + + "### How to Fix\n\n" + + "1. Go to **Settings** → **Actions** → **General**\n" + + "2. Scroll to the **Workflow permissions** section\n" + + "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + + "4. Click **Save**\n\n" + + "### Documentation\n\n" + + "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + + "### Workflow Details\n\n" + + "- **Workflow**: " + + workflowName + + "\n" + + "- **Run**: " + + runUrl + + "\n" + + (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + + "\n"; + + // Search for existing issue with the same title + const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; + const searchResult = await github.rest.search.issuesAndPullRequests({ + q: searchQuery, + per_page: 1, + }); + + if (searchResult.data.total_count > 0) { + const existingIssue = searchResult.data.items[0]; + core.info("Issue already exists: #" + existingIssue.number); + + // Add a comment with run details + const commentBody = "This error occurred again in workflow run: " + runUrl; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: existingIssue.number, + body: commentBody, + }); + core.info("Added comment to existing issue #" + existingIssue.number); + } else { + // Create new issue + const { data: issue } = await github.rest.issues.create({ + owner, + repo, + title: issueTitle, + body: issueBody, + labels: ["agentic-workflows", "configuration"], + }); + core.info("Created issue #" + issue.number + ": " + issue.html_url); + } +} + +module.exports = { main }; diff --git a/pkg/workflow/notify_comment.go b/pkg/workflow/notify_comment.go index 882dc94050..cb292daf49 100644 --- a/pkg/workflow/notify_comment.go +++ b/pkg/workflow/notify_comment.go @@ -188,85 +188,14 @@ func (c *Compiler) buildConclusionJob(data *WorkflowData, mainJobName string, sa createPRErrorEnvVars = append(createPRErrorEnvVars, buildWorkflowMetadataEnvVarsWithTrackerID(data.Name, data.Source, data.TrackerID)...) createPRErrorEnvVars = append(createPRErrorEnvVars, " GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\n") - // Inline script for handling create PR errors - createPRErrorScript := ` -const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; -if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; -} - -// Check if this is the permission error -if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; -} - -core.info("Creating issue for create_pull_request permission error"); - -const { owner, repo } = context.repo; -const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; -const runUrl = process.env.GH_AW_RUN_URL || ""; -const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; -const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - -const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - -const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - -// Search for existing issue with the same title -const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; -const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, -}); - -if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - - // Add a comment with run details - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); -} else { - // Create new issue - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); -} -` - // Build the create PR error handling step createPRErrorSteps := c.buildGitHubScriptStepWithoutDownload(data, GitHubScriptStepConfig{ StepName: "Handle Create Pull Request Error", StepID: "handle_create_pr_error", MainJobName: mainJobName, CustomEnvVars: createPRErrorEnvVars, - Script: createPRErrorScript, - ScriptFile: "", // Inline script, no file + Script: "const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); await main();", + ScriptFile: "handle_create_pr_error.cjs", Token: "", // Will use default GITHUB_TOKEN }) steps = append(steps, createPRErrorSteps...) From 705b87e5871070ca084ae47b4f9c820166254b81 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 23 Jan 2026 02:02:28 +0000 Subject: [PATCH 6/7] Recompile all workflows with new error handler - All workflows with create-pull-request now use handle_create_pr_error.cjs - Changed from inline script to require() pattern across all workflows - 24 workflow lock files updated with the new handler Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/ci-coach.lock.yml | 59 ++----------------- .github/workflows/cloclo.lock.yml | 59 ++----------------- .../workflows/code-scanning-fixer.lock.yml | 59 ++----------------- .github/workflows/code-simplifier.lock.yml | 59 ++----------------- .github/workflows/daily-doc-updater.lock.yml | 59 ++----------------- .../workflows/daily-workflow-updater.lock.yml | 59 ++----------------- .github/workflows/dependabot-bundler.lock.yml | 59 ++----------------- .../developer-docs-consolidator.lock.yml | 59 ++----------------- .github/workflows/dictation-prompt.lock.yml | 59 ++----------------- .../github-mcp-tools-report.lock.yml | 59 ++----------------- .../workflows/glossary-maintainer.lock.yml | 59 ++----------------- .github/workflows/go-logger.lock.yml | 59 ++----------------- .github/workflows/hourly-ci-cleaner.lock.yml | 59 ++----------------- .../workflows/instructions-janitor.lock.yml | 59 ++----------------- .github/workflows/jsweep.lock.yml | 59 ++----------------- .../workflows/layout-spec-maintainer.lock.yml | 59 ++----------------- .github/workflows/poem-bot.lock.yml | 59 ++----------------- .github/workflows/q.lock.yml | 59 ++----------------- .../workflows/secret-scanning-triage.lock.yml | 59 ++----------------- .../workflows/slide-deck-maintainer.lock.yml | 59 ++----------------- .../workflows/technical-doc-writer.lock.yml | 59 ++----------------- .github/workflows/tidy.lock.yml | 59 ++----------------- .../workflows/ubuntu-image-analyzer.lock.yml | 59 ++----------------- .github/workflows/unbloat-docs.lock.yml | 59 ++----------------- 24 files changed, 96 insertions(+), 1320 deletions(-) diff --git a/.github/workflows/ci-coach.lock.yml b/.github/workflows/ci-coach.lock.yml index d6cf3e62ce..ffb2eb867a 100644 --- a/.github/workflows/ci-coach.lock.yml +++ b/.github/workflows/ci-coach.lock.yml @@ -1624,61 +1624,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/cloclo.lock.yml b/.github/workflows/cloclo.lock.yml index cc8cdcfd5c..be37a143c4 100644 --- a/.github/workflows/cloclo.lock.yml +++ b/.github/workflows/cloclo.lock.yml @@ -1404,61 +1404,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/code-scanning-fixer.lock.yml b/.github/workflows/code-scanning-fixer.lock.yml index 29c30c64ca..e8a028e0e5 100644 --- a/.github/workflows/code-scanning-fixer.lock.yml +++ b/.github/workflows/code-scanning-fixer.lock.yml @@ -1111,61 +1111,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/code-simplifier.lock.yml b/.github/workflows/code-simplifier.lock.yml index 0accb0871f..2357255a73 100644 --- a/.github/workflows/code-simplifier.lock.yml +++ b/.github/workflows/code-simplifier.lock.yml @@ -1264,61 +1264,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/daily-doc-updater.lock.yml b/.github/workflows/daily-doc-updater.lock.yml index ba41486c90..9a139cdca2 100644 --- a/.github/workflows/daily-doc-updater.lock.yml +++ b/.github/workflows/daily-doc-updater.lock.yml @@ -1121,61 +1121,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/daily-workflow-updater.lock.yml b/.github/workflows/daily-workflow-updater.lock.yml index e8835aed0b..fa45ae81a4 100644 --- a/.github/workflows/daily-workflow-updater.lock.yml +++ b/.github/workflows/daily-workflow-updater.lock.yml @@ -1025,61 +1025,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/dependabot-bundler.lock.yml b/.github/workflows/dependabot-bundler.lock.yml index 191955e8e1..32b8c0935b 100644 --- a/.github/workflows/dependabot-bundler.lock.yml +++ b/.github/workflows/dependabot-bundler.lock.yml @@ -1013,61 +1013,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/developer-docs-consolidator.lock.yml b/.github/workflows/developer-docs-consolidator.lock.yml index 40f6d978da..47dc072caa 100644 --- a/.github/workflows/developer-docs-consolidator.lock.yml +++ b/.github/workflows/developer-docs-consolidator.lock.yml @@ -1668,61 +1668,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/dictation-prompt.lock.yml b/.github/workflows/dictation-prompt.lock.yml index 9c25caf72c..0a8ad9ae74 100644 --- a/.github/workflows/dictation-prompt.lock.yml +++ b/.github/workflows/dictation-prompt.lock.yml @@ -986,61 +986,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/github-mcp-tools-report.lock.yml b/.github/workflows/github-mcp-tools-report.lock.yml index 3884a134fd..08524a58f8 100644 --- a/.github/workflows/github-mcp-tools-report.lock.yml +++ b/.github/workflows/github-mcp-tools-report.lock.yml @@ -1515,61 +1515,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/glossary-maintainer.lock.yml b/.github/workflows/glossary-maintainer.lock.yml index 029f9dac1c..48d1e8a5b6 100644 --- a/.github/workflows/glossary-maintainer.lock.yml +++ b/.github/workflows/glossary-maintainer.lock.yml @@ -1655,61 +1655,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/go-logger.lock.yml b/.github/workflows/go-logger.lock.yml index 6f431a4e36..70ea41c021 100644 --- a/.github/workflows/go-logger.lock.yml +++ b/.github/workflows/go-logger.lock.yml @@ -1229,61 +1229,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/hourly-ci-cleaner.lock.yml b/.github/workflows/hourly-ci-cleaner.lock.yml index 0c0831db2a..b3e4570831 100644 --- a/.github/workflows/hourly-ci-cleaner.lock.yml +++ b/.github/workflows/hourly-ci-cleaner.lock.yml @@ -1257,61 +1257,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/instructions-janitor.lock.yml b/.github/workflows/instructions-janitor.lock.yml index 71992009fe..18ec6f09aa 100644 --- a/.github/workflows/instructions-janitor.lock.yml +++ b/.github/workflows/instructions-janitor.lock.yml @@ -1109,61 +1109,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/jsweep.lock.yml b/.github/workflows/jsweep.lock.yml index aeb0238044..154e588eb8 100644 --- a/.github/workflows/jsweep.lock.yml +++ b/.github/workflows/jsweep.lock.yml @@ -1141,61 +1141,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/layout-spec-maintainer.lock.yml b/.github/workflows/layout-spec-maintainer.lock.yml index f81e48d72c..6c33123013 100644 --- a/.github/workflows/layout-spec-maintainer.lock.yml +++ b/.github/workflows/layout-spec-maintainer.lock.yml @@ -1146,61 +1146,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/poem-bot.lock.yml b/.github/workflows/poem-bot.lock.yml index f50523df17..75a0bd74f5 100644 --- a/.github/workflows/poem-bot.lock.yml +++ b/.github/workflows/poem-bot.lock.yml @@ -1599,61 +1599,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/q.lock.yml b/.github/workflows/q.lock.yml index cfb5b0f731..65780fb5e7 100644 --- a/.github/workflows/q.lock.yml +++ b/.github/workflows/q.lock.yml @@ -1393,61 +1393,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/secret-scanning-triage.lock.yml b/.github/workflows/secret-scanning-triage.lock.yml index 47caab0dd3..8b8c6f4a19 100644 --- a/.github/workflows/secret-scanning-triage.lock.yml +++ b/.github/workflows/secret-scanning-triage.lock.yml @@ -1077,61 +1077,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/slide-deck-maintainer.lock.yml b/.github/workflows/slide-deck-maintainer.lock.yml index 067e07c7e0..18b04b03d1 100644 --- a/.github/workflows/slide-deck-maintainer.lock.yml +++ b/.github/workflows/slide-deck-maintainer.lock.yml @@ -1156,61 +1156,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/technical-doc-writer.lock.yml b/.github/workflows/technical-doc-writer.lock.yml index 6b06c63a39..f3fd99e579 100644 --- a/.github/workflows/technical-doc-writer.lock.yml +++ b/.github/workflows/technical-doc-writer.lock.yml @@ -1557,61 +1557,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/tidy.lock.yml b/.github/workflows/tidy.lock.yml index a97307fff9..8fc718b971 100644 --- a/.github/workflows/tidy.lock.yml +++ b/.github/workflows/tidy.lock.yml @@ -1038,61 +1038,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/ubuntu-image-analyzer.lock.yml b/.github/workflows/ubuntu-image-analyzer.lock.yml index 5206338e3d..c44cf09d1a 100644 --- a/.github/workflows/ubuntu-image-analyzer.lock.yml +++ b/.github/workflows/ubuntu-image-analyzer.lock.yml @@ -1314,61 +1314,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.github/workflows/unbloat-docs.lock.yml b/.github/workflows/unbloat-docs.lock.yml index d124d0758b..cdc4d9f176 100644 --- a/.github/workflows/unbloat-docs.lock.yml +++ b/.github/workflows/unbloat-docs.lock.yml @@ -1517,61 +1517,10 @@ jobs: with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} script: | - const errorMessage = process.env.CREATE_PR_ERROR_MESSAGE; - if (!errorMessage) { - core.info("No create_pull_request error message - skipping"); - return; - } - if (!errorMessage.includes("GitHub Actions is not permitted to create or approve pull requests")) { - core.info("Not a permission error - skipping"); - return; - } - core.info("Creating issue for create_pull_request permission error"); - const { owner, repo } = context.repo; - const workflowName = process.env.GH_AW_WORKFLOW_NAME || "unknown"; - const runUrl = process.env.GH_AW_RUN_URL || ""; - const workflowSource = process.env.GH_AW_WORKFLOW_SOURCE || ""; - const workflowSourceURL = process.env.GH_AW_WORKFLOW_SOURCE_URL || ""; - const issueTitle = "[agentic-workflows] GitHub Actions needs permission to create pull requests"; - const issueBody = "## GitHub Actions Permission Required\n\n" + - "The workflow **" + workflowName + "** attempted to create a pull request but failed because GitHub Actions is not permitted to create or approve pull requests in this repository.\n\n" + - "### How to Fix\n\n" + - "1. Go to **Settings** → **Actions** → **General**\n" + - "2. Scroll to the **Workflow permissions** section\n" + - "3. Check the box: **Allow GitHub Actions to create and approve pull requests**\n" + - "4. Click **Save**\n\n" + - "### Documentation\n\n" + - "For more information, see: [Managing GitHub Actions settings for a repository](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#preventing-github-actions-from-creating-or-approving-pull-requests)\n\n" + - "### Workflow Details\n\n" + - "- **Workflow**: " + workflowName + "\n" + - "- **Run**: " + runUrl + "\n" + - (workflowSourceURL ? "- **Source**: [" + workflowSource + "](" + workflowSourceURL + ")\n" : "") + "\n"; - const searchQuery = "repo:" + owner + "/" + repo + ' is:issue is:open in:title "' + issueTitle + '"'; - const searchResult = await github.rest.search.issuesAndPullRequests({ - q: searchQuery, - per_page: 1, - }); - if (searchResult.data.total_count > 0) { - const existingIssue = searchResult.data.items[0]; - core.info("Issue already exists: #" + existingIssue.number); - const commentBody = "This error occurred again in workflow run: " + runUrl; - await github.rest.issues.createComment({ - owner, - repo, - issue_number: existingIssue.number, - body: commentBody, - }); - core.info("Added comment to existing issue #" + existingIssue.number); - } else { - const { data: issue } = await github.rest.issues.create({ - owner, - repo, - title: issueTitle, - body: issueBody, - labels: ["agentic-workflows", "configuration"], - }); - core.info("Created issue #" + issue.number + ": " + issue.html_url); - } + const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); + setupGlobals(core, github, context, exec, io); + const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs'); + await main(); - name: Update reaction comment with completion status id: conclusion uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 From 40623c6687c99b40b62686b3274fbb55f343a129 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Jan 2026 02:09:01 +0000 Subject: [PATCH 7/7] Add changeset [skip-ci] --- .../patch-handle-create-pr-permission-error.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/patch-handle-create-pr-permission-error.md diff --git a/.changeset/patch-handle-create-pr-permission-error.md b/.changeset/patch-handle-create-pr-permission-error.md new file mode 100644 index 0000000000..fcac308ae6 --- /dev/null +++ b/.changeset/patch-handle-create-pr-permission-error.md @@ -0,0 +1,12 @@ +--- +"gh-aw": patch +--- + +Handle GitHub Actions PR creation permission errors by setting an `error_message` output +and adding an auto-filed issue handler with guidance when Actions cannot create or +approve pull requests in the repository. + +This patch documents the change: the create-pull-request flow now emits a helpful +`error_message` output when permissions block PR creation, and the conclusion job +can use that to file or update an issue with next steps and links to documentation. +