-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 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,45 @@ | ||
name: Create PR from main to production | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
create-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Fetch all branches | ||
run: git fetch --all | ||
|
||
- name: Check if there are changes between main and production | ||
id: check_diff | ||
run: | | ||
git checkout main | ||
git pull origin main | ||
git checkout production | ||
git pull origin production | ||
DIFF=$(git diff main production) | ||
if [ -z "$DIFF" ]; then | ||
echo "No changes detected." | ||
echo "::set-output name=changes::false" | ||
else | ||
echo "Changes detected." | ||
echo "::set-output name=changes::true" | ||
fi | ||
- name: Create Pull Request | ||
if: steps.check_diff.outputs.changes == 'true' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
source: main | ||
destination: production | ||
title: 'Update production branch' | ||
body: 'This PR updates the production branch with changes from the main branch.' | ||
draft: false | ||
base: production | ||
branch: main |