Last active
January 7, 2025 16:01
-
-
Save TSMMark/ce8e82c5f8fdc7dd3581832ebd0158d6 to your computer and use it in GitHub Desktop.
GH Action Workflow to merge master into current branch when a label is added to a PR
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
# .github/workflows/update_with_latest_master.yml | |
# | |
# This is a Github Action Workflow to merge master into current branch when a label is added to a PR. | |
# Label: `update with latest master` | |
# | |
# 1) Add this yml file to your github workflows directory. | |
# 2) Add the issue/pr label: `update with latest master` to your project. | |
# 3) Any time you want to merge master into a branch, just add the `update with latest master` label to it! | |
# | |
# NOTE: This will trigger a new commit on your branch, potentially triggering CI, and other workflows. | |
# NOTE: If you've already added the label to a PR earlier but you need to update from master again, you can simply remove and re-add the label to the PR and it will trigger the action again! | |
name: Update with latest master | |
on: | |
pull_request: | |
types: [labeled] | |
jobs: | |
merge-branch: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Inject slug/short variables | |
# https://stackoverflow.com/a/58730805/2696867 | |
uses: rlespinasse/[email protected] | |
- name: Merge master -> current | |
# https://github.com/marketplace/actions/merge-branch#on-labeled | |
uses: devmasx/[email protected] | |
with: | |
label_name: 'update with latest master' | |
from_branch: master | |
target_branch: ${{ env.GITHUB_HEAD_REF_SLUG }} | |
github_token: ${{ github.token }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment