From 5b5d0e33a7c8bd828434eaca00df090fc8e9c444 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 15 Feb 2023 11:27:59 -0800 Subject: [PATCH] Update course content to remove `gh pr create` (#29) * 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 --- .github/workflows/0-start.yml | 4 -- ...yourself.yml => 1-open-a-pull-request.yml} | 19 +++--- ...ave-a-review.yml => 2-assign-yourself.yml} | 14 ++-- ...ggest-changes.yml => 3-leave-a-review.yml} | 14 ++-- ...pply-changes.yml => 4-suggest-changes.yml} | 16 ++--- .github/workflows/5-apply-changes.yml | 68 +++++++++++++++++++ ...uest.yml => 6-merge-your-pull-request.yml} | 12 ++-- README.md | 65 +++++++++++++----- 8 files changed, 156 insertions(+), 56 deletions(-) rename .github/workflows/{1-assign-yourself.yml => 1-open-a-pull-request.yml} (78%) rename .github/workflows/{2-leave-a-review.yml => 2-assign-yourself.yml} (87%) rename .github/workflows/{3-suggest-changes.yml => 3-leave-a-review.yml} (89%) rename .github/workflows/{4-apply-changes.yml => 4-suggest-changes.yml} (87%) create mode 100644 .github/workflows/5-apply-changes.yml rename .github/workflows/{5-merge-your-pull-request.yml => 6-merge-your-pull-request.yml} (87%) diff --git a/.github/workflows/0-start.yml b/.github/workflows/0-start.yml index 0652689..d2056f8 100644 --- a/.github/workflows/0-start.yml +++ b/.github/workflows/0-start.yml @@ -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: diff --git a/.github/workflows/1-assign-yourself.yml b/.github/workflows/1-open-a-pull-request.yml similarity index 78% rename from .github/workflows/1-assign-yourself.yml rename to .github/workflows/1-open-a-pull-request.yml index 3509f5e..9da0ffb 100644 --- a/.github/workflows/1-assign-yourself.yml +++ b/.github/workflows/1-open-a-pull-request.yml @@ -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
and opens
-# 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: @@ -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 @@ -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
and open
# and set STEP to '2' diff --git a/.github/workflows/2-leave-a-review.yml b/.github/workflows/2-assign-yourself.yml similarity index 87% rename from .github/workflows/2-leave-a-review.yml rename to .github/workflows/2-assign-yourself.yml index b2029e8..cd1103f 100644 --- a/.github/workflows/2-leave-a-review.yml +++ b/.github/workflows/2-assign-yourself.yml @@ -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
and opens
-# 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: @@ -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: diff --git a/.github/workflows/3-suggest-changes.yml b/.github/workflows/3-leave-a-review.yml similarity index 89% rename from .github/workflows/3-suggest-changes.yml rename to .github/workflows/3-leave-a-review.yml index 3606348..d53e1b9 100644 --- a/.github/workflows/3-suggest-changes.yml +++ b/.github/workflows/3-leave-a-review.yml @@ -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
and opens
-# 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: @@ -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: diff --git a/.github/workflows/4-apply-changes.yml b/.github/workflows/4-suggest-changes.yml similarity index 87% rename from .github/workflows/4-apply-changes.yml rename to .github/workflows/4-suggest-changes.yml index 7a6706a..7ad382e 100644 --- a/.github/workflows/4-apply-changes.yml +++ b/.github/workflows/4-suggest-changes.yml @@ -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
and opens
-# 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: @@ -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: diff --git a/.github/workflows/5-apply-changes.yml b/.github/workflows/5-apply-changes.yml new file mode 100644 index 0000000..6182fca --- /dev/null +++ b/.github/workflows/5-apply-changes.yml @@ -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
and opens
+ +# 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
and open
+ # 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 diff --git a/.github/workflows/5-merge-your-pull-request.yml b/.github/workflows/6-merge-your-pull-request.yml similarity index 87% rename from .github/workflows/5-merge-your-pull-request.yml rename to .github/workflows/6-merge-your-pull-request.yml index aba3087..8f9b554 100644 --- a/.github/workflows/5-merge-your-pull-request.yml +++ b/.github/workflows/6-merge-your-pull-request.yml @@ -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
and opens
+# This step closes
and opens
# 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 @@ -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 @@ -56,12 +56,12 @@ jobs: with: fetch-depth: 0 # Let's get all the branches - # Update README to close
and open
+ # Update README to close
and open
# 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 diff --git a/README.md b/README.md index 666f208..631913e 100644 --- a/README.md +++ b/README.md @@ -50,33 +50,66 @@ All great projects start with collaboration. Pull requests are the foundation of -->
-

Step 1: Assign yourself as a reviewer

+

Step 1: Open a pull request

_Welcome to "Review pull requests"! :wave:_ +Let's get started by opening a pull request. + +**What is a pull request?**: Collaboration happens on a pull request. The pull request shows the changes in your branch to other people. This pull request is going to keep the changes you just made on your branch and propose applying them to the `main` branch. + +### :keyboard: Activity: Create a pull request + +1. Click on the **Pull requests** tab in your repository. +2. Click **New pull request**. +3. In the **base:** dropdown, make sure **main** is selected. +4. Select the **compare:** dropdown, and click `update-branch`. +5. Click **Create pull request**. +6. Enter a title for your pull request: `Update the game over message`. +7. Enter a description for your pull request: `Update the game over message so people know how to play again!` +8. Click **Create pull request**. + +Next, wait about 20 seconds for actions to run, then refresh this course's README (the one you're following instructions from) and a [GitHub Action](https://docs.github.com/en/actions) will automatically close this step and open the next one. + +
+ + + +
+

Step 2: Assign yourself

+ +_Great job opening that pull request! :wave:_ + **What is a _pull request review_?**: Reviewing a pull request is an opportunity to examine another contributor's changes and give them feedback. It's an awesome opportunity to learn more about how the project works and how others solve problems. -The best way to get a review is to ask for one. On GitHub, you can ask someone to review a pull request by assigning them as a reviewer. If you are not ready for review, consider [creating a draft 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) instead. +The best way to get a review is to ask for one. On GitHub, you can ask someone to review a pull request by assigning them as a reviewer or assignee. If you are not ready for review, consider [creating a draft 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) instead. ### :keyboard: Activity: Assign yourself as a reviewer 1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab. 1. We made a pull request for you from the `update-game` branch, so open that pull request. -1. Under **Reviewers** on the right side of the screen, add yourself as a reviewer. +1. Under **Assignees** on the right side of the screen, add yourself as a reviewer. + +Because you created the pull request, you can't assign yourself as a reviewer, but feel free to assign a friend to see how it works :smile: Next, wait about 20 seconds for actions to run, then refresh this course's README (the one you're following instructions from) and a [GitHub Action](https://docs.github.com/en/actions) will automatically close this step and open the next one.
-
-

Step 2: Leave a review

+
+

Step 3: Leave a review

_You assigned yourself as a reviewer! :tada:_ @@ -106,7 +139,7 @@ When an approval or request for changes is not yet needed, consider using **comm 1. On the pull request, click **Files changed**. 1. Click **Review changes**. 1. Add a comment with your initial thoughts on the pull request. -1. Select _comment_, _approve_, or _request changes_: any option will work. +1. Select _comment_ or _request changes_: either option will work. You won't be able to _approve_ your own pull request. 1. Click **Submit review**. Next, wait about 20 seconds for actions to run, then refresh this course's README (the one you're following instructions from) and a [GitHub Action](https://docs.github.com/en/actions) will automatically close this step and open the next one. @@ -114,13 +147,13 @@ Next, wait about 20 seconds for actions to run, then refresh this course's READM
-
-

Step 3: Suggest changes

+
+

Step 4: Suggest changes

_Nice work reviewing that pull request :sparkles:_ @@ -144,13 +177,13 @@ Next, wait about 20 seconds for actions to run, then refresh this course's READM
-
-

Step 4: Apply suggested changes

+
+

Step 5: Apply suggested changes

_Nicely done suggesting changes! :partying_face:_ @@ -167,13 +200,13 @@ Next, wait about 20 seconds for actions to run, then refresh this course's READM
-
-

Step 5: Merge your pull request

+
+

Step 6: Merge your pull request

_Almost there! :heart:_