Skip to content

Commit

Permalink
Merge pull request #126 from IABTechLab/ian-UID2-4254-promotion-auto-pr
Browse files Browse the repository at this point in the history
promotion auto pr
  • Loading branch information
Ian-Nara authored Oct 17, 2024
2 parents 536147d + ec2ff2d commit a84774c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/shared-promote-auto-pr.yaml
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 }}

0 comments on commit a84774c

Please sign in to comment.