-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (38 loc) · 1.18 KB
/
_pr-create.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
name: Create pull request to branch
on:
workflow_call:
inputs:
head:
type: string
default: ${{ github.ref_name }}
base:
required: true
type: string
env:
GH_TOKEN: ${{ github.token }}
HEAD: ${{ inputs.head }}
BASE: ${{ inputs.base }}
jobs:
create-pr:
runs-on: ubuntu-latest
outputs:
pr_number: ${{ steps.pr-number.outputs.pull_request_number }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check for existing PR
id: check-pr
run: |
PR=$(gh pr list --base ${BASE} --head ${HEAD} --json number --jq '.[0].number')
echo "::set-output name=pr_exists::$PR"
- name: Create pull request
if: steps.check-pr.outputs.pr_exists == ''
run: |
gh pr create \
--label "autogenerated" \
--base ${BASE} --head ${HEAD} \
--title "Deploy to ${BASE}" \
--body "Automated PR to sync changes from ${HEAD} to ${BASE}."
- name: Get pull request number
id: pr-number
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT