-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from IABTechLab/ian-UID2-4254-promotion-auto-pr
promotion auto pr
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 }} |