-
Notifications
You must be signed in to change notification settings - Fork 17
70 lines (63 loc) · 2.28 KB
/
pr-followup.yaml
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
62
63
64
65
66
67
68
69
70
name: Pull Request Follow-Up Flow
on:
# Checking out with pull_request_target should be safe because the jobs are run only when the PR is merged.
pull_request_target:
types: [closed]
jobs:
follow-up:
name: Pull Request Follow-Up
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- uses: actions/github-script@v2
id: head-branch
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const pull_request = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
return {
ref: pull_request.data.head.ref,
repo: pull_request.data.head.repo.full_name,
body: pull_request.data.body.replace(/\r?\n/g, '\n')
};
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.SG_REPO_GH_APP_ID }}
private_key: ${{ secrets.SG_REPO_GH_APP_PRIV_KEY }}
- name: Update snapshots
run: |
set -exo pipefail
git branch -v
git remote -v
git log -n 2
echo "$PR" | jq -r '.body' | sed -e '1,/^# Automatic follow-ups$/d' -e '/^- /!d' -e 's/^- \[[xX]\] Add to snapshot `\([^`]*\)` :: /\1.opam -- /' -e '/^[-+. [:alnum:]]*$/!d' | xargs -r -L1 scripts/update-snapshot --base 'origin/master~1' --opam
git status
env:
PR: ${{ steps.head-branch.outputs.result }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
id: cpr
with:
token: ${{ steps.generate-token.outputs.token }}
delete-branch: true
commit-message: Take snapshots
branch: 'follow-up/${{ github.event.pull_request.number }}'
title: '[Automated] Follow up #${{ github.event.pull_request.number }}'
body: |
Follow up #${{ github.event.pull_request.number }}
labels: |
automated pr
# assignees: na4zagin3
# reviewers: na4zagin3
team-reviewers: |
owners
maintainers