Skip to content

Commit 60f33b9

Browse files
build(java): auto-approve README regeneration (#1606)
Source-Author: Jeff Ching <[email protected]> Source-Date: Thu Oct 15 16:04:06 2020 -0700 Source-Repo: googleapis/synthtool Source-Sha: 7c5370937dd9ba9dcf9cd7d2af880a58b389b4f1 Source-Link: googleapis/synthtool@7c53709
1 parent 707d0fe commit 60f33b9

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

.github/workflows/approve-readme.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
on:
2+
pull_request:
3+
name: auto-merge-readme
4+
jobs:
5+
approve:
6+
runs-on: ubuntu-latest
7+
if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme'
8+
steps:
9+
- uses: actions/[email protected]
10+
with:
11+
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
12+
script: |
13+
// only approve PRs from yoshi-automation
14+
if (context.payload.pull_request.user.login !== "yoshi-automation") {
15+
return;
16+
}
17+
18+
// only approve PRs like "chore: release <release version>"
19+
if (!context.payload.pull_request.title === "chore: regenerate README") {
20+
return;
21+
}
22+
23+
// only approve PRs with README.md and synth.metadata changes
24+
const files = new Set(
25+
(
26+
await github.paginate(
27+
github.pulls.listFiles.endpoint({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
pull_number: context.payload.pull_request.number,
31+
})
32+
)
33+
).map(file => file.filename)
34+
);
35+
if (files.size != 2 || !files.has("README.md") || !files.has(".github/readme/synth.metadata/synth.metadata")) {
36+
return;
37+
}
38+
39+
// approve README regeneration PR
40+
await github.pulls.createReview({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
body: 'Rubber stamped PR!',
44+
pull_number: context.payload.pull_request.number,
45+
event: 'APPROVE'
46+
});
47+
48+
// attach automerge label
49+
await github.issues.addLabels({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
issue_number: context.payload.pull_request.number,
53+
labels: ['automerge']
54+
});

synth.metadata

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/google-api-java-client.git",
7-
"sha": "e395ed9bae57fe343225553850ff92c2c20cdaff"
7+
"sha": "326370e0ec4351aaea21da271692b2fb9585a28c"
88
}
99
},
1010
{
1111
"git": {
1212
"name": "synthtool",
1313
"remote": "https://github.com/googleapis/synthtool.git",
14-
"sha": "27e0e916cbfdb3d5ff6639b686cc04f78a0b0386"
14+
"sha": "7c5370937dd9ba9dcf9cd7d2af880a58b389b4f1"
1515
}
1616
}
1717
],
@@ -24,6 +24,7 @@
2424
".github/readme/synth.py",
2525
".github/release-please.yml",
2626
".github/trusted-contribution.yml",
27+
".github/workflows/approve-readme.yaml",
2728
".github/workflows/auto-release.yaml",
2829
".github/workflows/ci.yaml",
2930
".github/workflows/formatting.yaml",

0 commit comments

Comments
 (0)