-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (54 loc) · 1.81 KB
/
auto-copilot.yml
File metadata and controls
61 lines (54 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Auto Approve Copilot
on:
pull_request_target:
types: [opened, synchronize]
permissions:
actions: write
pull-requests: write
jobs:
auto-copilot:
if: github.actor == 'Copilot'
runs-on: ubuntu-latest
steps:
- name: Mark PR as ready for review
if: github.event.pull_request.draft
uses: actions/github-script@v7
with:
script: |
await github.graphql(`
mutation {
markPullRequestReadyForReview(input: {
pullRequestId: "${context.payload.pull_request.node_id}"
}) {
pullRequest { isDraft }
}
}
`);
console.log('PR marked as ready for review');
- name: Wait for CI workflows to register
run: sleep 30
- name: Approve pending workflow runs
uses: actions/github-script@v7
with:
script: |
const { data: runs } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
status: 'action_required',
head_sha: context.payload.pull_request.head.sha,
});
for (const run of runs.workflow_runs) {
try {
await github.rest.actions.approveWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id,
});
console.log(`Approved workflow run: ${run.id} (${run.name})`);
} catch (e) {
console.log(`Failed to approve run ${run.id}: ${e.message}`);
}
}
if (runs.workflow_runs.length === 0) {
console.log('No pending workflow runs to approve');
}