Skip to content

Commit

Permalink
Update course content to remove gh pr create (#29)
Browse files Browse the repository at this point in the history
* Update course content to remove gh create pr

* Update .github/workflows/2-assign-yourself.yml

* Update .github/workflows/4-suggest-changes.yml

* Update .github/workflows/4-suggest-changes.yml
  • Loading branch information
heiskr committed Feb 15, 2023
1 parent b22514a commit 5b5d0e3
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 56 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/0-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ jobs:
echo "Push"
git push --set-upstream origin $BRANCH
echo "Make a pull request"
# Reference https://cli.github.com/manual/gh_pr_create
gh pr create --title "Update the game over message" --body "Update the game over message so people know how to play again!"
echo "Restore main"
git checkout main
env:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: Step 1, Assign yourself
name: Step 1, Open a pull request

# This step triggers after the user assigns themselves as a pull request reviewer
# This step listens for the learner to open a pull request with branch `update-game`
# This step sets STEP to 2
# This step closes <details id=1> and opens <details id=2>

# This will run every time someone is assigned as a pull request reviewer
# This will run every time we create a branch or tag
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
workflow_dispatch:
pull_request:
types:
- review_requested
- opened
- reopened

# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
Expand All @@ -33,18 +34,20 @@ jobs:
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_assigned_reviewer:
name: On assigned reviewer
on_open_a_pull_request:
name: On open a pull request
needs: get_current_step

# We will only run this action when:
# 1. This repository isn't the template repository
# 2. The STEP is currently 1
# 3. The head branch name is `update-game`
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 1 }}
&& needs.get_current_step.outputs.current_step == 1
&& github.head_ref == 'update-game' }}
# We'll run Ubuntu for performance instead of Mac or Windows
runs-on: ubuntu-latest
Expand All @@ -55,7 +58,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0 # Let's get all the branches
ref: update-game
ref: update-game # Important, as normally `pull_request` event won't grab other branches

# Update README to close <details id=1> and open <details id=2>
# and set STEP to '2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Step 2, Leave a review
name: Step 2, Assign yourself

# This step triggers after the user leaves a pull request review
# This step triggers after the user assigns themselves as a pull request reviewer
# This step sets STEP to 3
# This step closes <details id=2> and opens <details id=3>

# This will run every time we leave a pull request review
# This will run every time someone is assigned as a pull request reviewer
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
workflow_dispatch:
pull_request_review:
pull_request:
types:
- submitted
- review_requested

# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
Expand All @@ -33,8 +33,8 @@ jobs:
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_leave_review:
name: On leave review
on_assigned_reviewer:
name: On assigned reviewer
needs: get_current_step

# We will only run this action when:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Step 3, Suggest changes
name: Step 3, Leave a review

# This step triggers after the user leaves a review comment
# This step triggers after the user leaves a pull request review
# This step sets STEP to 4
# This step closes <details id=3> and opens <details id=4>

# This will run every time we leave a review comment
# This will run every time we leave a pull request review
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
workflow_dispatch:
pull_request_review_comment:
pull_request_review:
types:
- created
- submitted

# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
Expand All @@ -33,8 +33,8 @@ jobs:
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_review_comment:
name: On review comment
on_leave_review:
name: On leave review
needs: get_current_step

# We will only run this action when:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Step 4, Apply changes
name: Step 4, Suggest changes

# This step triggers after the user applies the pull request suggested change
# This step triggers after the user leaves a review comment
# This step sets STEP to 5
# This step closes <details id=4> and opens <details id=5>

# This will run every time we push to the `update-game branch`
# This will run every time we leave a review comment
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
workflow_dispatch:
push:
branches:
- update-game
pull_request_review_comment:
types:
- created

# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
Expand All @@ -33,8 +33,8 @@ jobs:
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_apply_suggested_change:
name: On apply suggested change
on_review_comment:
name: On review comment
needs: get_current_step

# We will only run this action when:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/5-apply-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Step 5, Apply changes

# This step triggers after the user applies the pull request suggested change
# This step sets STEP to 6
# This step closes <details id=5> and opens <details id=6>

# This will run every time we push to the `update-game branch`
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
on:
workflow_dispatch:
push:
branches:
- update-game

# Reference https://docs.github.com/en/actions/security-guides/automatic-token-authentication
permissions:
# Need `contents: read` to checkout the repository
# Need `contents: write` to update the step metadata
contents: write

jobs:
# Get the current step from .github/script/STEP so we can
# limit running the main job when the learner is on the same step.
get_current_step:
name: Check current step number
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- id: get_step
run: |
echo "current_step=$(cat ./.github/script/STEP)" >> $GITHUB_OUTPUT
outputs:
current_step: ${{ steps.get_step.outputs.current_step }}

on_apply_suggested_change:
name: On apply suggested change
needs: get_current_step

# We will only run this action when:
# 1. This repository isn't the template repository
# 2. The STEP is currently 5
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 5 }}
# We'll run Ubuntu for performance instead of Mac or Windows
runs-on: ubuntu-latest

steps:
# We'll need to check out the repository so that we can edit the README
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # Let's get all the branches
ref: update-game

# Update README to close <details id=5> and open <details id=6>
# and set STEP to '6'
- name: Update to step 6
uses: skills/action-update-step@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 5
to_step: 6
branch_name: update-game
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Step 5, Merge your pull request
name: Step 6, Merge your pull request

# This step triggers after a pull requst is merged to `main`
# This step sets STEP to X
# This step closes <details id=5> and opens <details id=X>
# This step closes <details id=6> and opens <details id=X>

# This will run every time we create push a commit to `main`
# Reference https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
Expand Down Expand Up @@ -39,12 +39,12 @@ jobs:

# We will only run this action when:
# 1. This repository isn't the template repository
# 2. The STEP is currently 5
# 2. The STEP is currently 6
# Reference https://docs.github.com/en/actions/learn-github-actions/contexts
# Reference https://docs.github.com/en/actions/learn-github-actions/expressions
if: >-
${{ !github.event.repository.is_template
&& needs.get_current_step.outputs.current_step == 5 }}
&& needs.get_current_step.outputs.current_step == 6 }}
# We'll run Ubuntu for performance instead of Mac or Windows
runs-on: ubuntu-latest
Expand All @@ -56,12 +56,12 @@ jobs:
with:
fetch-depth: 0 # Let's get all the branches

# Update README to close <details id=5> and open <details id=X>
# Update README to close <details id=6> and open <details id=X>
# and set STEP to 'X'
- name: Update to step X
uses: skills/action-update-step@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
from_step: 5
from_step: 6
to_step: X
branch_name: update-game
Loading

0 comments on commit 5b5d0e3

Please sign in to comment.