Skip to content

Commit e6deaea

Browse files
authored
Need to create PR manually (skills#13)
* no more gh pr * Add new step for initial merge conflict * rename workflows since there's a new step/workflow * update step numbers * New learner step and steps bump * now step 4 * add wait 20 seconds note
1 parent 423b2f7 commit e6deaea

File tree

6 files changed

+152
-54
lines changed

6 files changed

+152
-54
lines changed

.github/workflows/0-start.yml

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ on:
1616
permissions:
1717
# Need `contents: read` to checkout the repository
1818
# Need `contents: write` to update the step metadata
19-
# Need `pull-requests: write` to create a pull request
2019
contents: write
21-
pull-requests: write
2220

2321
jobs:
2422
# Get the current step from .github/script/STEP so we can
@@ -58,7 +56,7 @@ jobs:
5856
with:
5957
fetch-depth: 0 # Let's get all the branches
6058

61-
- name: Prepare a branch, pull request, and merge conflict
59+
- name: Prepare a branch
6260
run: |
6361
echo "Make sure we are on step 0"
6462
if [ "$(cat .github/script/STEP)" != 0 ]
@@ -82,21 +80,6 @@ jobs:
8280
8381
echo "Push"
8482
git push --set-upstream origin $BRANCH
85-
86-
echo "Make a pull request"
87-
# Reference https://cli.github.com/manual/gh_pr_create
88-
gh pr create --title "Resolving merge conflicts" --body "Resolving merge conflicts"
89-
90-
echo "Restore main"
91-
git checkout main
92-
93-
echo "Create a merge conflict"
94-
sed -i.bak 's/Experience/Jobs/' resume.md
95-
git add resume.md
96-
git commit --message="Update resume.md in main"
97-
98-
echo "Push"
99-
git push origin main
10083
env:
10184
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10285

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Step 1, Create a pull request
2+
3+
# This step triggers after the learner creates a pull request for the my-resume branch
4+
# This step sets STEP to 2
5+
# This step closes <details id=1> and opens <details id=2>
6+
7+
# This will run every time we open a pull request
8+
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
9+
on:
10+
workflow_dispatch:
11+
pull_request:
12+
types: [opened]
13+
14+
# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
15+
permissions:
16+
# Need `contents: read` to checkout the repository
17+
# Need `contents: write` to update the step metadata
18+
contents: write
19+
20+
jobs:
21+
# Get the current step from .github/script/STEP so we can
22+
# limit running the main job when the learner is on the same step.
23+
get_current_step:
24+
name: Check current step number
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
- id: get_step
30+
run: |
31+
echo "current_step=$(cat ./.github/script/STEP)" >> $GITHUB_OUTPUT
32+
outputs:
33+
current_step: ${{ steps.get_step.outputs.current_step }}
34+
35+
on_create_pr:
36+
name: On create PR
37+
needs: get_current_step
38+
39+
# We will only run this action when:
40+
# 1. This repository isn't the template repository
41+
# 2. The STEP is currently 1
42+
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
43+
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
44+
if: >-
45+
${{ !github.event.repository.is_template
46+
&& needs.get_current_step.outputs.current_step == 1 }}
47+
48+
# We'll run Ubuntu for performance instead of Mac or Windows
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
# We'll need to check out the repository so that we can edit the README
53+
- name: Checkout
54+
uses: actions/checkout@v3
55+
with:
56+
fetch-depth: 0 # Let's get all the branches
57+
58+
- name: Prepare a merge conflict
59+
run: |
60+
echo "Make sure we are on step 1"
61+
if [ "$(cat .github/script/STEP)" != 1 ]
62+
then
63+
echo "Current step is not 1"
64+
exit 0
65+
fi
66+
67+
echo "Manually update STEP in my-resume to match STEP in main branch"
68+
git checkout my-resume
69+
git config user.name github-actions
70+
git config user.email [email protected]
71+
sed -i.bak 's/1/2/' .github/script/STEP
72+
git add .github/script/STEP
73+
git commit --message="Update STEP in my-resume"
74+
echo "Push"
75+
git push origin my-resume
76+
77+
echo "Create a merge conflict in main"
78+
git checkout main
79+
sed -i.bak 's/Experience/Jobs/' resume.md
80+
git add resume.md
81+
git commit --message="Update resume.md in main"
82+
83+
echo "Push"
84+
git push origin main
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
88+
# Update README to close <details id=1> and open <details id=2>
89+
# and set STEP to '2'
90+
- name: Update to step 2
91+
uses: skills/action-update-step@v1
92+
with:
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
from_step: 1
95+
to_step: 2
96+
branch_name: my-resume

.github/workflows/1-resolve-a-merge-conflict.yml renamed to .github/workflows/2-resolve-a-merge-conflict.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Step 1, Resolve a merge conflict
1+
name: Step 2, Resolve a merge conflict
22

33
# This step triggers after the user resolves the merge conflict
4-
# This step sets STEP to 2
5-
# This step closes <details id=1> and opens <details id=2>
4+
# This step sets STEP to 3
5+
# This step closes <details id=2> and opens <details id=3>
66

77
# This will run every time we push to `my-resume` (this will be a merge commit
88
# since the user is resolving a merge conflict)
@@ -40,12 +40,12 @@ jobs:
4040

4141
# We will only run this action when:
4242
# 1. This repository isn't the template repository
43-
# 2. The STEP is currently 1
43+
# 2. The STEP is currently 2
4444
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
4545
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
4646
if: >-
4747
${{ !github.event.repository.is_template
48-
&& needs.get_current_step.outputs.current_step == 1 }}
48+
&& needs.get_current_step.outputs.current_step == 2 }}
4949
5050
# We'll run Ubuntu for performance instead of Mac or Windows
5151
runs-on: ubuntu-latest
@@ -60,10 +60,10 @@ jobs:
6060

6161
- name: Create and push a new file on main
6262
run: |
63-
echo "Make sure we are on step 1"
64-
if [ "$(cat .github/script/STEP)" != 1 ]
63+
echo "Make sure we are on step 2"
64+
if [ "$(cat .github/script/STEP)" != 2 ]
6565
then
66-
echo "Current step is not 1"
66+
echo "Current step is not 2"
6767
exit 0
6868
fi
6969
@@ -84,12 +84,12 @@ jobs:
8484
env:
8585
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8686

87-
# Update README to close <details id=1> and open <details id=2>
88-
# and set STEP to '2'
89-
- name: Update to step 2
87+
# Update README to close <details id=2> and open <details id=3>
88+
# and set STEP to '3'
89+
- name: Update to step 3
9090
uses: skills/action-update-step@v1
9191
with:
9292
token: ${{ secrets.GITHUB_TOKEN }}
93-
from_step: 1
94-
to_step: 2
93+
from_step: 2
94+
to_step: 3
9595
branch_name: my-resume

.github/workflows/2-create-your-own-conflict.yml renamed to .github/workflows/3-create-your-own-conflict.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Step 2, Create your own conflict
1+
name: Step 3, Create your own conflict
22

33
# This step triggers after the user creates `references.md` in the `my-resume` branch
4-
# This step sets STEP to 3
5-
# This step closes <details id=2> and opens <details id=3>
4+
# This step sets STEP to 4
5+
# This step closes <details id=3> and opens <details id=4>
66

77
# This will run every time we push to the `reference.md` file in the `my-resume` branch
88
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
@@ -41,12 +41,12 @@ jobs:
4141

4242
# We will only run this action when:
4343
# 1. This repository isn't the template repository
44-
# 2. The STEP is currently 2
44+
# 2. The STEP is currently 3
4545
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
4646
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
4747
if: >-
4848
${{ !github.event.repository.is_template
49-
&& needs.get_current_step.outputs.current_step == 2 }}
49+
&& needs.get_current_step.outputs.current_step == 3 }}
5050
5151
# We'll run Ubuntu for performance instead of Mac or Windows
5252
runs-on: ubuntu-latest
@@ -60,11 +60,11 @@ jobs:
6060
ref: my-resume
6161

6262
# Update README to close <details id=2> and open <details id=3>
63-
# and set STEP to '3'
64-
- name: Update to step 3
63+
# and set STEP to '4'
64+
- name: Update to step 4
6565
uses: skills/action-update-step@v1
6666
with:
6767
token: ${{ secrets.GITHUB_TOKEN }}
68-
from_step: 2
69-
to_step: 3
68+
from_step: 3
69+
to_step: 4
7070
branch_name: my-resume

.github/workflows/3-merge-your-pull-request.yml renamed to .github/workflows/4-merge-your-pull-request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Step 3, Merge your pull request
1+
name: Step 4, Merge your pull request
22

33
# This step triggers after a pull requst is merged to `main`
44
# This step sets STEP to X
@@ -39,12 +39,12 @@ jobs:
3939

4040
# We will only run this action when:
4141
# 1. This repository isn't the template repository
42-
# 2. The STEP is currently 3
42+
# 2. The STEP is currently 4
4343
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
4444
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
4545
if: >-
4646
${{ !github.event.repository.is_template
47-
&& needs.get_current_step.outputs.current_step == 3 }}
47+
&& needs.get_current_step.outputs.current_step == 4 }}
4848
4949
# We'll run Ubuntu for performance instead of Mac or Windows
5050
runs-on: ubuntu-latest
@@ -62,6 +62,6 @@ jobs:
6262
uses: skills/action-update-step@v1
6363
with:
6464
token: ${{ secrets.GITHUB_TOKEN }}
65-
from_step: 3
65+
from_step: 4
6666
to_step: X
6767
branch_name: my-resume

README.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,37 @@ Merge conflicts happen when two people make changes to the same file on GitHub
5050
-->
5151

5252
<details id=1>
53-
<summary><h2>Step 1: Resolve a merge conflict</h2></summary>
53+
<summary><h2>Step 1: Create a pull request</h2></summary>
5454

5555
_Welcome to "Managing Merge Conflicts"! :wave:_
5656

57-
**What is a _merge conflict_?**: A **merge conflict** occurs when changes are made to the same part of the same file on two different branches. You usually find out about conflicts in a pull request.
57+
**What is a _merge conflict_?**: A **merge conflict** occurs when changes are made to the same part of the same file on two different branches. You usually find out about conflicts in a pull request so let's start by creating one.
58+
59+
### :keyboard: Activity: Create a pull request
60+
61+
1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab.
62+
1. We made a small change to a file in the repository in the `my-resume` branch.
63+
1. [Create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) setting `my-resume` as the head branch and `main` as the base branch. You can enter `Resolving merge conflicts` for the pull request title and body.
64+
1. Wait about 20 seconds then refresh this page for the next step.
65+
66+
</details>
67+
68+
<!--
69+
<<< Author notes: Step 2 >>>
70+
Start this step by acknowledging the previous step.
71+
Define terms and link to docs.github.com.
72+
-->
73+
74+
<details id=2>
75+
<summary><h2>Step 2: Resolve a merge conflict</h2></summary>
76+
77+
_Good start! Now let's look deeper at a merge conflict! :mag:_
5878

5979
This can be intimidating, but have no fear, Git is smart when it comes to merging! Git only needs a human to decide how to [resolve the conflict](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line). Sometimes, the best way to resolve a merge conflict is to add content that's from both branches, or even something that isn't on either! This is why Git needs a human to look at the code and make the proper fixes.
6080

6181
### :keyboard: Activity: Resolve a merge conflict
6282

63-
1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab.
64-
1. Open the pull request we made for you. We also made a conflict. Have no fear!
83+
1. Open the pull request that you just created, we created a conflict for you. Have no fear!
6584
1. At the bottom of the page, under "This branch has conflicts that must be resolved", click the **Resolve conflicts** button.
6685
1. Look for the highlighted sections that begins with `<<<<<<< my-resume` and ends with `>>>>>>> main`. These markers are added by Git to show you the content that is in conflict.
6786
1. Remove the changes made on the main branch by deleting all of the content below the `=======` and above `>>>>>>> main`.
@@ -78,13 +97,13 @@ This can be intimidating, but have no fear, Git is smart when it comes to mergin
7897
</details>
7998

8099
<!--
81-
<<< Author notes: Step 2 >>>
100+
<<< Author notes: Step 3 >>>
82101
Start this step by acknowledging the previous step.
83102
Define terms and link to docs.github.com.
84103
-->
85104

86-
<details id=2>
87-
<summary><h2>Step 2: Create your own conflict</h2></summary>
105+
<details id=3>
106+
<summary><h2>Step 3: Create your own conflict</h2></summary>
88107

89108
_Good job! You've solved a merge conflict! :tada:_
90109

@@ -107,13 +126,13 @@ We went ahead and added a new file called `references.md` and pushed that change
107126
</details>
108127

109128
<!--
110-
<<< Author notes: Step 3 >>>
129+
<<< Author notes: Step 4 >>>
111130
Start this step by acknowledging the previous step.
112131
Define terms and link to docs.github.com.
113132
-->
114133

115-
<details id=3>
116-
<summary><h2>Step 3: Merge your pull request</h2></summary>
134+
<details id=4>
135+
<summary><h2>Step 4: Merge your pull request</h2></summary>
117136

118137
_Almost there! :heart:_
119138

0 commit comments

Comments
 (0)