diff --git a/.github/script/merge-branch.sh b/.github/script/merge-branch.sh new file mode 100644 index 0000000..7cbacfd --- /dev/null +++ b/.github/script/merge-branch.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Make sure this file is executable +# chmod +x .github/script/merge-branch.sh + +# USAGE: This script is used to merge a branch into another branch + +# BACKGROUND: This operation is required to avoid conflicts between branches. + +# Setup commiter identity +git config user.name github-actions +git config user.email github-actions@github.com + +# Merge branch +echo "If branch $branch2 exists, merge branch origin $branch1 into branch $branch2" +if git show-ref --quiet refs/heads/$branch2 +then + git checkout $branch2 + git merge origin $branch1 + git push origin $branch2 +else + echo "Branch $branch2 does not exist" +fi diff --git a/.github/steps/5-merge-your-pull-request.md b/.github/steps/5-merge-your-pull-request.md index 5fe659c..f3c3ebe 100644 --- a/.github/steps/5-merge-your-pull-request.md +++ b/.github/steps/5-merge-your-pull-request.md @@ -13,6 +13,5 @@ You can now [merge](https://docs.github.com/get-started/quickstart/github-glossa ### :keyboard: Activity: Merge your pull request 1. Go to the **Pull requests** tab. -1. Resolve any merge conflicts. 1. Click **Merge pull request**. 1. _Once you turn on branch protection, Actions can no longer push directly to the `main` branch. Make sure that you're on the `ci` branch in the page you're following instructions from._ Wait about 20 seconds and then refresh the page. [GitHub Actions](https://docs.github.com/actions) will automatically update to the next step. diff --git a/.github/workflows/4-add-branch-protections.yml b/.github/workflows/4-add-branch-protections.yml index 24f2dfd..d1839b6 100644 --- a/.github/workflows/4-add-branch-protections.yml +++ b/.github/workflows/4-add-branch-protections.yml @@ -56,6 +56,11 @@ jobs: fetch-depth: 0 # Let's get all the branches. ref: ci # Important, as normally `branch_protection_rule` event won't grab other branches + - name: Merge changes from origin main into ci + run: ./.github/script/merge-branch.sh + env: + branch1: main + branch2: ci # TODO: figure out a better way to deal with the merge conflict. # In README.md, switch step 4 for step 5.