Skip to content

Commit

Permalink
chore: Implement auto-approval of autosynth PRs (googleapis#740)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Oss <6331106+codyoss@users.noreply.github.com>
Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and myusuf3 committed Dec 4, 2020
1 parent 9b9df65 commit 3c0ae55
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/autoapprove.yml
@@ -0,0 +1,49 @@
name: AutoApprove

on:
pull_request:
branches:
- master
types:
- opened

jobs:
auto-approve:
runs-on: ubuntu-latest
if: contains(github.head_ref, 'autosynth')
env:
ENABLE_AUTO_APPROVE: ${{ secrets.ENABLE_AUTO_APPROVE }}
steps:
- name: AutoApprove
uses: actions/github-script@v2
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!");

0 comments on commit 3c0ae55

Please sign in to comment.