File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
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 }}
You can’t perform that action at this time.
0 commit comments