-
-
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 #312 from zackproser/auto-pr-main-into-staging
Add GitHub Action to open PRs against staging with main's latest changes
- Loading branch information
Showing
1 changed file
with
47 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,47 @@ | ||
# This workflow keeps the staging branch up to date with the main branch | ||
# by creating a pull request against staging with the latest changes from main | ||
# whenever there was a merge to main that didn't go through staging, such as | ||
# small feature branches, new blog posts, etc. | ||
# name: Update Staging with Main branch changes | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
update-staging: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
# Get information about the last merge commit | ||
- name: Get Last Merge Commit | ||
id: last_merge_commit | ||
run: | | ||
merge_commit_sha=$(git log -1 --format=format:%H --merges) | ||
echo "Merge Commit SHA: $merge_commit_sha" | ||
merge_commit_message=$(git log -1 --format=format:%B --merges) | ||
echo "::set-output name=sha::$merge_commit_sha" | ||
echo "::set-output name=message::$merge_commit_message" | ||
# Optional: Check for a keyword in merge commit message to decide | ||
- name: Check if Merge is from Staging | ||
id: check_merge | ||
run: | | ||
if [[ "${{ steps.last_merge_commit.outputs.message }}" == | ||
*"Merge pull request #"*"from user/staging"* ]]; then | ||
echo "Merge is from staging branch. Skip PR creation." | ||
echo "::set-output name=skip::true" | ||
else | ||
echo "Merge is NOT from staging branch." | ||
echo "::set-output name=skip::false" | ||
fi | ||
|
||
- name: Create pull request | ||
if: steps.check_merge.outputs.skip != 'true' | ||
uses: repo-sync/pull-request@v2 | ||
with: | ||
destination_branch: "staging" | ||
source_branch: "main" | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |