-
Notifications
You must be signed in to change notification settings - Fork 29
47 lines (46 loc) · 1.76 KB
/
Pull Request Action.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
name: Pull Request Action
'on':
push:
branches:
- dev
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- name: Check if PR exists
id: check
run: |
prs=$(gh pr list --repo "$GITHUB_REPOSITORY" \
--json baseRefName,headRefName \
--jq '
map(select(.baseRefName == "master" and .headRefName == "dev"))
| length
')
if ((prs > 0)); then
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create pull request
if: steps.check.outputs.skip != 'true'
uses: actions/github-script@v6
with:
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: 'Master Sync : Auto Generated PR',
owner,
repo,
head: '${{ github.ref_name }}',
base: 'master',
body: [
'This PR is auto-generated by',
'[actions/github-script](https://github.com/actions/github-script).'
].join('\n')
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['feature', 'automated pr']
});