|
1 |
| -name: Step 1, Create a pull request |
| 1 | +name: Step 1 |
2 | 2 |
|
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 |
8 | 3 | on:
|
9 |
| - workflow_dispatch: |
10 | 4 | pull_request:
|
11 |
| - types: [opened] |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - reopened |
12 | 8 |
|
13 |
| -# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication |
14 | 9 | permissions:
|
15 |
| - # Need `contents: read` to checkout the repository. |
16 |
| - # Need `contents: write` to update the step metadata. |
17 | 10 | contents: write
|
| 11 | + actions: write |
| 12 | + issues: write |
18 | 13 |
|
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" |
32 | 16 |
|
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] |
45 | 21 |
|
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] |
47 | 25 | runs-on: ubuntu-latest
|
| 26 | + env: |
| 27 | + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} |
48 | 28 |
|
49 | 29 | steps:
|
50 |
| - # We'll need to check out the repository so that we can edit the README. |
51 | 30 | - name: Checkout
|
52 | 31 | uses: actions/checkout@v4
|
| 32 | + |
| 33 | + - name: Get response templates |
| 34 | + uses: actions/checkout@v4 |
53 | 35 | 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 |
55 | 39 |
|
56 |
| - - name: Prepare a merge conflict |
| 40 | + - name: Create comment - add step content |
57 | 41 | 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 }} |
80 | 46 |
|
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 |
83 | 51 | env:
|
84 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
85 | 53 |
|
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