-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (48 loc) · 1.41 KB
/
autopr.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
name: Auto PR
on:
push:
branches:
- 'autopr/**'
permissions: read-all
jobs:
create-pull-request:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Create PR
uses: actions/github-script@v7
with:
script: |
const { repo, owner } = context.repo;
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: context.ref,
base: 'main',
state: 'open',
});
if (pulls.data.length < 1) {
await github.rest.pulls.create({
title: '[AUTOPR] Automatic updates',
owner: owner,
repo: repo,
head: context.ref,
base: 'main',
body: [
'This PR is auto-generated by',
'[actions/github-script](https://github.com/actions/github-script)',
].join('\n'),
});
} else {
const existingPR = pulls.data[0];
await github.rest.pulls.update({
owner: owner,
repo: repo,
pull_number: existingPR.number,
body: [
existingPR.body,
`Updated by Job ${context.job}`,
].join('\n'),
});
}