-
Notifications
You must be signed in to change notification settings - Fork 1.1k
51 lines (48 loc) · 1.73 KB
/
autoapprove.yml
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
name: AutoApprove
on:
pull_request:
branches:
- main
types:
- opened
permissions: write-all
jobs:
auto-approve:
runs-on: ubuntu-latest
if: contains(github.head_ref, 'discogen')
env:
ENABLE_AUTO_APPROVE: ${{ secrets.ENABLE_AUTO_APPROVE }}
steps:
- name: AutoApprove
uses: actions/github-script@v6
with:
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
script: |
if (context.payload.sender.login != "yoshi-automation") {
core.error("AutoApprove: Not running for this sender.");
return;
}
if (!context.payload.pull_request.title.startsWith("feat(all): auto-regenerate")) {
core.error("AutoApprove: Not running for this PR title.");
return;
}
if (!process.env.ENABLE_AUTO_APPROVE) {
core.error("AutoApprove: PR conditions passed but ENABLE_AUTO_APPROVE is not set.");
return;
}
core.info("AutoApprove: PR conditions passed!");
await github.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
body: "AutoApprove: Rubber stamped client regeneration!",
pull_number: context.payload.pull_request.number,
event: "APPROVE"
});
core.info("AutoApprove: Rubber stamped client regeneration!");
await github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["automerge"]
});
core.info("AutoApprove: Applied automerge label!");