-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (38 loc) · 1.29 KB
/
create-pr-next-main.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
name: create-pr-next-main
run-name: ${{ github.actor }} is making a PR from next into main.
on:
push:
branches:
- next
jobs:
create-pr:
name: Create PR
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: next
- name: Check if PR already exists
id: check-pr-exists
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
prs=$(gh pr list -B main -H next)
# Even when there are no PRs, this array always seems to have 1 result
echo Size of PRS ARRAY: ${#prs[@]}
# Locally, it seems the gh cli says 'no pull requests match your search..' but not here.
# The first element exists but is of length 0
echo Length of PRS[0] string: ${#prs[0]}
if ((${#prs[@]} > 0 && ${#prs[0]} != 0 )); then
echo skipping PR creation
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Create PR
if: '!steps.check-pr-exists.outputs.skip'
run: gh pr create -B main -H next --title 'Merge Next into Main' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}