-
Notifications
You must be signed in to change notification settings - Fork 1
34 lines (32 loc) · 1.15 KB
/
shared-promote-auto-pr.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
name: Create Deployment Pull Request
on:
workflow_call:
jobs:
create_pr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create Pull Request
run: |
echo "branch ${{ github.ref }} was pushed to"
if [ ${{ github.ref }} == "refs/heads/main" ]; then
base="test"
elif [ ${{ github.ref }} == "refs/heads/test" ]; then
base="integ"
elif [ ${{ github.ref }} == "refs/heads/integ" ]; then
base="prod"
else
exit 0
fi
echo "promotion is to ${base}"
# Check if a PR already exists
existing_pr=$(gh pr list --base ${base} --head main --state open --json number --jq '.[0].number')
if [ -z "$existing_pr" ]; then
echo "No existing PR found. Creating a new PR."
gh pr create --base ${base} --head main --title "PR from main to ${base}" --body "Automated PR from main to ${base} branch"
else
echo "PR already exists: #$existing_pr"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}