Skip to content

Commit be52676

Browse files
committed
updated sstructure
1 parent edd3b7c commit be52676

11 files changed

+331
-367
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/steps/-step.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/steps/0-welcome.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Step 0
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
issues: write
12+
13+
env:
14+
STEP_1_FILE: ".github/steps/1-open-a-pull-request.md"
15+
16+
jobs:
17+
start_exercise:
18+
if: |
19+
!github.event.repository.is_template
20+
name: Start Exercise
21+
uses: skills/exercise-toolkit/.github/workflows/[email protected]
22+
with:
23+
exercise-title: "Review Pull Requests"
24+
intro-message: "Let's learn to collaborate with others using pull requests."
25+
26+
modify_repo_content:
27+
name: Modify repo content
28+
runs-on: ubuntu-latest
29+
needs: [start_exercise]
30+
env:
31+
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Prepare a branch and pull request
38+
run: |
39+
40+
echo "Make a branch"
41+
BRANCH=update-game
42+
git checkout -b $BRANCH
43+
44+
echo "Update index.html"
45+
sed -i.bak 's/Game over/Game over, refresh to play again 🧑‍💻 🤖!/' index.html
46+
47+
echo "Make a commit"
48+
git config user.name github-actions[bot]
49+
git config user.email github-actions[bot]@users.noreply.github.com
50+
git add index.html
51+
git commit --message="Update game over message"
52+
53+
echo "Push"
54+
git push --set-upstream origin $BRANCH
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
post_next_step_content:
59+
name: Post next step content
60+
runs-on: ubuntu-latest
61+
needs: [start_exercise]
62+
env:
63+
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
64+
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v4
68+
69+
- name: Get response templates
70+
uses: actions/checkout@v4
71+
with:
72+
repository: skills/exercise-toolkit
73+
path: exercise-toolkit
74+
ref: v0.5.0
75+
76+
- name: Build comment - add step content
77+
id: build-comment
78+
uses: skills/action-text-variables@v2
79+
with:
80+
template-file: ${{ env.STEP_1_FILE }}
81+
template-vars: |
82+
login: ${{ github.actor }}
83+
full_repo_name: ${{ github.repository }}
84+
85+
- name: Create comment - add step content
86+
run: |
87+
gh issue comment "$ISSUE_URL" \
88+
--body "$ISSUE_BODY"
89+
env:
90+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91+
ISSUE_BODY: ${{ steps.build-comment.outputs.updated-text }}
92+
93+
- name: Create comment - watching for progress
94+
run: |
95+
gh issue comment "$ISSUE_URL" \
96+
--body-file "exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md"
97+
env:
98+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Enable next step workflow
101+
run: |
102+
gh workflow enable "Step 1"
103+
env:
104+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/0-welcome.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 39 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,59 @@
1-
name: Step 1, Create a pull request
1+
name: Step 1
22

3-
# This step triggers after the learner creates a pull request for the my-resume branch
4-
# This workflow updates from step 1 to step 2.
5-
6-
# This will run every time we open a pull request.
7-
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
83
on:
9-
workflow_dispatch:
104
pull_request:
11-
types: [opened]
5+
types:
6+
- opened
7+
- reopened
128

13-
# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
149
permissions:
15-
# Need `contents: read` to checkout the repository.
16-
# Need `contents: write` to update the step metadata.
1710
contents: write
11+
actions: write
12+
issues: write
1813

19-
jobs:
20-
# Get the current step to only run the main job when the learner is on the same step.
21-
get_current_step:
22-
name: Check current step number
23-
runs-on: ubuntu-latest
24-
steps:
25-
- name: Checkout
26-
uses: actions/checkout@v4
27-
- id: get_step
28-
run: |
29-
echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT
30-
outputs:
31-
current_step: ${{ steps.get_step.outputs.current_step }}
14+
env:
15+
STEP_2_FILE: ".github/steps/2-assign-yourself.md"
3216

33-
on_create_pr:
34-
name: On create PR
35-
needs: get_current_step
36-
37-
# We will only run this action when:
38-
# 1. This repository isn't the template repository.
39-
# 2. The step is currently 1.
40-
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
41-
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
42-
if: >-
43-
${{ !github.event.repository.is_template
44-
&& needs.get_current_step.outputs.current_step == 1 }}
17+
jobs:
18+
find_exercise:
19+
name: Find Exercise Issue
20+
uses: skills/exercise-toolkit/.github/workflows/[email protected]
4521

46-
# We'll run Ubuntu for performance instead of Mac or Windows.
22+
post_next_step_content:
23+
name: Post next step content
24+
needs: [find_exercise]
4725
runs-on: ubuntu-latest
26+
env:
27+
ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
4828

4929
steps:
50-
# We'll need to check out the repository so that we can edit the README.
5130
- name: Checkout
5231
uses: actions/checkout@v4
32+
33+
- name: Get response templates
34+
uses: actions/checkout@v4
5335
with:
54-
fetch-depth: 0 # Let's get all the branches.
36+
repository: skills/exercise-toolkit
37+
path: exercise-toolkit
38+
ref: v0.5.0
5539

56-
- name: Prepare a merge conflict
40+
- name: Create comment - add step content
5741
run: |
58-
echo "Make sure we are on step 1"
59-
if [ "$(cat .github/steps/-step.txt)" != 1 ]
60-
then
61-
echo "Current step is not 1"
62-
exit 0
63-
fi
64-
65-
echo "Manually update step in my-resume to match step in main branch"
66-
git checkout my-resume
67-
git config user.name github-actions[bot]
68-
git config user.email github-actions[bot]@users.noreply.github.com
69-
sed -i.bak 's/1/2/' .github/steps/-step.txt
70-
git add .github/steps/-step.txt
71-
git commit --message="Update step in my-resume"
72-
echo "Push"
73-
git push origin my-resume
74-
75-
echo "Create a merge conflict in main"
76-
git checkout main
77-
sed -i.bak 's/Experience/Jobs/' resume.md
78-
git add resume.md
79-
git commit --message="Update resume.md in main"
42+
gh issue comment "$ISSUE_URL" \
43+
--body-file "$STEP_2_FILE"
44+
env:
45+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8046

81-
echo "Push"
82-
git push origin main
47+
- name: Create comment - watching for progress
48+
run: |
49+
gh issue comment "$ISSUE_URL" \
50+
--body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
8351
env:
84-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8553

86-
# In README.md, switch step 1 for step 2.
87-
- name: Update to step 2
88-
uses: skills/action-update-step@v2
89-
with:
90-
token: ${{ secrets.GITHUB_TOKEN }}
91-
from_step: 1
92-
to_step: 2
93-
branch_name: my-resume
54+
- name: Disable current workflow and enable next one
55+
run: |
56+
gh workflow disable "Step 1"
57+
gh workflow enable "Step 2"
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)