forked from segler-alex/RadioDroid
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (59 loc) · 1.93 KB
/
re-run-pull-request-github-actions.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Re-run CI tests on open PRs
on:
push:
branches:
- master
jobs:
re-run-github-actions:
runs-on: ubuntu-latest
steps:
- name: (GET-&-PUT GitHub API) Push empty commit to PR branch
uses: actions/[email protected]
with:
github-token: ${{secrets.PAT}}
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const {data: pullRequests} = await github.pulls.list({
owner,
repo,
base: "master",
state: "open",
});
for (pr of pullRequests) {
try {
let pullReq = {};
while (pullReq.mergeable === undefined || pullReq.mergeable === null) {
pullReq = (
await github.pulls.get({
owner,
repo,
pull_number: pr.number,
})
).data;
}
if(pullReq.mergeable === false) continue;
const {data: commitData} = await github.repos.getCommit({
owner,
repo,
ref: pullReq.head.sha,
});
const {data: createdCommit} = await github.git.createCommit({
owner,
repo,
message: "trigger github actions",
tree: commitData.commit.tree.sha,
parents: [commitData.sha],
commiter: context.payload.pusher,
author: context.payload.pusher,
});
await github.git.updateRef({
owner,
repo,
ref: `heads/${pr.head.ref}`,
sha: createdCommit.sha,
});
} catch (err) {
console.log(err);
}
}