diff --git a/.github/workflows/report-workflow-failures.yml b/.github/workflows/report-workflow-failures.yml index 8c367668552..858cc0df09b 100644 --- a/.github/workflows/report-workflow-failures.yml +++ b/.github/workflows/report-workflow-failures.yml @@ -21,6 +21,7 @@ jobs: issues: write steps: - name: Create or update issue + id: report uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: script: | @@ -95,11 +96,26 @@ jobs: const body = [ issueMarker, + `*Generated by the [${context.workflow} workflow](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}).*`, + '', 'The following jobs are failing in this workflow:', '', ...failedJobListItems, '', 'cc @github/primer-engineering to investigate and fix', + '', + '
', + 'Agent instructions', + '', + 'Investigate this workflow failure and determine whether it needs a change in this repository.', + '', + '- Review the failed jobs, their logs, and recent runs of the same workflow.', + '- Assess whether the failure is intermittent or caused by an external service disruption, outage, or other transient infrastructure issue.', + '- If the failure has an actionable cause in this repository, implement the smallest appropriate fix and verify it addresses the failure.', + '- Do not make speculative code changes when the evidence points to a transient or external cause.', + '- If you decide not to attempt a fix, leave a comment on this issue explaining the evidence and rationale for that decision.', + '', + '
', ].join('\n'); const issue = { @@ -107,6 +123,7 @@ jobs: repo: context.repo.repo, title, body, + type: 'Bug', }; let issueNumber; @@ -133,18 +150,43 @@ jobs: issueNumber = createdIssue.data.number; } - try { - await github.rest.issues.addAssignees({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - assignees: ['copilot'], - }); - } catch (error) { - core.warning( - `Failed to assign @copilot to issue #${issueNumber}. This is expected if Copilot assignment is not enabled for this repository. Error: ${error?.message ?? String(error)}`, - ); + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + labels: ['area: actions'], + }); + + core.setOutput('issue_number', issueNumber); + + - name: Assign issue to Copilot + if: ${{ steps.report.outputs.issue_number }} + continue-on-error: true + env: + GH_TOKEN: ${{ secrets.GH_AW_AGENT_TOKEN }} + ISSUE_NUMBER: ${{ steps.report.outputs.issue_number }} + assigned="$( + gh api \ + --method POST \ + -H 'Accept: application/vnd.github+json' \ + -H 'X-GitHub-Api-Version: 2022-11-28' \ + "/repos/${GITHUB_REPOSITORY}/issues/${ISSUE_NUMBER}/assignees" \ + --input - \ + --jq 'any(.assignees[]; .login == "copilot-swe-agent[bot]")' <