Skip to content

Commit a84774c

Browse files
authored
Merge pull request #126 from IABTechLab/ian-UID2-4254-promotion-auto-pr
promotion auto pr
2 parents 536147d + ec2ff2d commit a84774c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Create Deployment Pull Request
2+
on:
3+
workflow_call:
4+
jobs:
5+
create_pr:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout repository
9+
uses: actions/checkout@v4
10+
- name: Create Pull Request
11+
run: |
12+
echo "branch ${{ github.ref }} was pushed to"
13+
if [ ${{ github.ref }} == "refs/heads/main" ]; then
14+
base="test"
15+
elif [ ${{ github.ref }} == "refs/heads/test" ]; then
16+
base="integ"
17+
elif [ ${{ github.ref }} == "refs/heads/integ" ]; then
18+
base="prod"
19+
else
20+
exit 0
21+
fi
22+
echo "promotion is to ${base}"
23+
24+
# Check if a PR already exists
25+
existing_pr=$(gh pr list --base ${base} --head main --state open --json number --jq '.[0].number')
26+
27+
if [ -z "$existing_pr" ]; then
28+
echo "No existing PR found. Creating a new PR."
29+
gh pr create --base ${base} --head main --title "PR from main to ${base}" --body "Automated PR from main to ${base} branch"
30+
else
31+
echo "PR already exists: #$existing_pr"
32+
fi
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)