-
Notifications
You must be signed in to change notification settings - Fork 9
46 lines (43 loc) · 1.34 KB
/
update-prs.yml
File metadata and controls
46 lines (43 loc) · 1.34 KB
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
---
name: Update PRs
on:
push:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
permissions: {}
jobs:
update-prs:
if: startsWith(github.ref, 'refs/heads/')
permissions:
# Required to update the PR
pull-requests: write
# Required to update the PR branch
contents: write
runs-on: ubuntu-latest
steps:
- name: Update Pull Requests
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: |
const opts = github.rest.pulls.list.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
base: context.ref.replace('refs/heads/', ''),
})
const prs = await github.paginate(opts)
for (const pr of prs) {
core.debug(JSON.stringify(pr))
core.info(`Updating PR #${pr.number}`)
github.rest.pulls.updateBranch({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
}).then(function(result) {
core.debug(JSON.stringify(result))
core.info(JSON.stringify(result.data))
}).catch(function(error) {
core.error(error)
})
}