diff --git a/.github/steps/4-copilot-on-github.md b/.github/steps/4-copilot-on-github.md index e800c9a..26f35f6 100644 --- a/.github/steps/4-copilot-on-github.md +++ b/.github/steps/4-copilot-on-github.md @@ -1,39 +1,43 @@ ## Step 4: Using GitHub Copilot within a pull request -Congratulations! You are finished with coding for this exercise :tada: +Congratulations! You are finished with coding for this exercise. Now it's time to merge our work. :tada: To wrap up, let's learn about two limited-access Copilot features that can speed up our pull requests! -Now, let's see how Copilot can help us finish up with during our pull request. +#### Copilot Pull Request Summaries -### :keyboard: Activity: Summarize and review with Copilot :robot: +Typically, you would review your notes and commit messages then summarize them for your pull request description. This may take some time, especially if commit messages are inconsistent or code is not not documented well. Fortunately, Copilot can consider all changes in the pull request and provide the important highlights, and with references too! -1. In a web browser, navigate to your exercise repository. +> [!NOTE] +> This is a unavailable with the **Copilot Free** tier. [[docs]](https://docs.github.com/en/enterprise-cloud@latest/copilot/using-github-copilot/using-github-copilot-for-pull-requests/creating-a-pull-request-summary-with-github-copilot) -1. At the top, select the **Pull Requests** tab and create a new pull request. Stop when you reach a form to enter a title and description. +#### Copilot Review - - **base:** `main` - - **compare:** `accelerate-with-copilot` - - **title:** `Add registration validation and more activities` +More eyes on our work is always useful so let's ask Copilot to do a first pass before we do a normal peer review process. Copilot is great at catching common mistakes that can are fixed by simple adjustment, but please remember to use it responsibily. -1. **Use Copilot to add a description** - In the **Add a description** toolbar, click the **Copilot actions** icon and **Summary** action to describe your changes. :memo: +> [!IMPORTANT] +> This is in **Public Preview** for organizations. [[docs]](https://docs.github.com/en/copilot/using-github-copilot/code-review/using-copilot-code-review) -1. **Ask Copilot to review your changes** - In the right side information panel at the top, locate the **Reviewers** section and click the **Request** button next to a **Copilot icon**. +### :keyboard: Activity: Summarize and review a PR with Copilot -1. Below the pull request description, press the green **Create pull request** one more time. +Both **pull request summaries** and **copilot review** have limited access, so this activity is mostly optional. If you have access, Mona will gladly check your work though! If not, you can skip the optional steps. -1. Wait a moment for Copilot to add a review comment to your pull request! +1. In a web browser, open another tab and navigate to your exercise repository. - - Notice the log entry indicating a Copilot review was requested. +1. You might notice a **notification banner** suggesting to create a new pull request. Click that or use the **Pull Requests** tab at the top to create a new pull request. Please use the following details: -1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this lesson! + - **base:** `main` + - **compare:** `accelerate-with-copilot` + - **title:** `Add registration validation and more activities` + +1. (Optional) In the **Add a description** area, enter edit mode if needed, then click the **Copilot actions** icon and **Summary** action. After a moment, Copilot will add a description. :memo: -1. At the bottom, press the green **Merge pull request** button. Nice work! You are all done! :tada: + Copilot summarize button -
-Having trouble? 🤷
+1. (Optional) In the right side information panel at the top, locate the **Reviewers** section and click the **Request** button next to a **Copilot icon**. Wait a moment for Copilot to add a review comment to your pull request! -If you don't get feedback, here are some things to check: + Copilot review button -- Make sure Copilot generated a description. -- Make sure Copilot was requested to provide a review. + > **Tip:** Notice a log entry that Copilot was requested for a review. -
+1. At the bottom, press the **Merge pull request** button. Nice work! You are all done! :tada: + +1. Wait a moment for Mona to check your work, provide feedback, and post a final review of this lesson! diff --git a/.github/workflows/3-copilot-edits.yml b/.github/workflows/3-copilot-edits.yml index e0d4dc0..5034ee5 100644 --- a/.github/workflows/3-copilot-edits.yml +++ b/.github/workflows/3-copilot-edits.yml @@ -204,6 +204,7 @@ jobs: - name: Disable current workflow and enable next one run: | gh workflow disable "Step 3" - gh workflow enable "Step 4" + gh workflow enable "Step 4a" + gh workflow enable "Step 4b" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4a-copilot-on-github.yml b/.github/workflows/4a-copilot-on-github.yml new file mode 100644 index 0000000..ecfdc1d --- /dev/null +++ b/.github/workflows/4a-copilot-on-github.yml @@ -0,0 +1,171 @@ +name: Step 4a # Copilot on GitHub + +on: + pull_request: + branches: + - main + types: + - closed + +permissions: + contents: write + actions: write + issues: write + +env: + REVIEW_FILE: ".github/steps/x-review.md" + +jobs: + find_exercise: + if: | + !github.event.repository.is_template + name: Find exercise by issue title + runs-on: ubuntu-latest + + outputs: + issue-url: ${{ steps.get-issue-url.outputs.ISSUE_URL }} + + steps: + - id: get-issue-url + run: | + # Get the issue url from the event or search for it. + if [ -n "${{ github.event.issue }}" ]; then + issue_url="${{ github.event.issue.html_url }}" + else + issue_url=$(gh issue list --repo $REPO --search "in:title Exercise:" --json url,title --jq '.[].url') + fi + + # Save to output + echo "ISSUE_URL=$issue_url" >> $GITHUB_OUTPUT + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + + check_step_work: + name: Check step work + runs-on: ubuntu-latest + needs: [find_exercise] + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/response-templates + path: skills-response-templates + + # START: Check practical exercise + + # Nothing to check. Merging the pull request is enough. + + # END: Check practical exercise + + - name: Create comment - step finished - final review next + run: | + gh issue comment "$ISSUE_URL" \ + --body-file skills-response-templates/step-feedback/lesson-review.md + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + post_review_content: + name: Post review content + needs: [find_exercise, check_step_work] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/response-templates + path: skills-response-templates + + - name: Create comment - add step content + run: | + gh issue comment "$ISSUE_URL" \ + --body-file "$REVIEW_FILE" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + finish_exercise: + name: Finish exercise + needs: [find_exercise, post_review_content] + runs-on: ubuntu-latest + env: + ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: main + + - name: Get response templates + uses: actions/checkout@v4 + with: + repository: skills/response-templates + path: skills-response-templates + + - name: Configure Git user + run: | + git config user.name github-actions[bot] + git config user.email github-actions[bot]@users.noreply.github.com + + - name: Build message - congratulations + id: build-message-congratulations + uses: skills/action-text-variables@v1 + with: + template-file: skills-response-templates/readme/congratulations.md + template-vars: | + login=${{ github.actor }} + + - name: Update README - congratulations + run: | + # Add "Congratulations" to the start of the README + orig_readme=$(cat README.md) + new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme" + + # Update file and push + echo "$new_readme" > README.md + git add README.md + git commit --message="Congratulations!🎉" + git push + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build message - exercise finished + id: build-finish-message + uses: skills/action-text-variables@v1 + with: + template-file: skills-response-templates/step-feedback/lesson-finished.md + template-vars: | + login=${{ github.actor }} + repo_full_name=${{ github.repository }} + + - name: Create comment - exercise finished + run: | + gh issue comment "$ISSUE_URL" \ + --body "$ISSUE_BODY" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }} + + - name: Close issue + run: gh issue close "$ISSUE_URL" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Disable current workflow + run: | + gh workflow disable "Step 4a" + gh workflow disable "Step 4b" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/4-copilot-on-github.yml b/.github/workflows/4b-copilot-on-github.yml similarity index 55% rename from .github/workflows/4-copilot-on-github.yml rename to .github/workflows/4b-copilot-on-github.yml index 3d72910..38cc2dd 100644 --- a/.github/workflows/4-copilot-on-github.yml +++ b/.github/workflows/4b-copilot-on-github.yml @@ -1,10 +1,14 @@ -name: Step 4 # Copilot on GitHub +name: Step 4b # Copilot on GitHub on: - pull_request: - branches: - - main - types: [edited] + # Trigger if PR Description is edited + # pull_request: + # branches: + # - main + # types: + # - edited + + # Trigger if Copilot adds a review comment pull_request_review: permissions: @@ -14,9 +18,6 @@ permissions: pull-requests: read repository-projects: read -env: - REVIEW_FILE: ".github/steps/x-review.md" - jobs: find_exercise: if: | @@ -60,16 +61,9 @@ jobs: repository: skills/response-templates path: skills-response-templates - - name: Update comment - checking work - run: | - gh issue comment "$ISSUE_URL" \ - --body-file skills-response-templates/step-feedback/checking-work.md \ - --edit-last - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # START: Check practical exercise - - name: Check participant info on activity cards + + - name: Check for pr description and copilot review id: check-user-work run: | # Checks to perform @@ -143,8 +137,7 @@ jobs: - name: Create comment - step results run: | gh issue comment "$ISSUE_URL" \ - --body "$COMMENT_BODY" \ - --edit-last + --body "$COMMENT_BODY" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMMENT_BODY: ${{ steps.build-message-step-results.outputs.updated-text }} @@ -154,107 +147,3 @@ jobs: run: exit 1 # END: Check practical exercise - - - name: Update comment - step finished - final review next - run: | - gh issue comment "$ISSUE_URL" \ - --body-file skills-response-templates/step-feedback/lesson-review.md - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - post_review_content: - name: Post review content - needs: [find_exercise, check_step_work] - runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/response-templates - path: skills-response-templates - - - name: Create comment - add step content - run: | - gh issue comment "$ISSUE_URL" \ - --body-file "$REVIEW_FILE" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - finish_exercise: - name: Finish exercise - needs: [find_exercise, post_review_content] - runs-on: ubuntu-latest - env: - ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: main - - - name: Get response templates - uses: actions/checkout@v4 - with: - repository: skills/response-templates - path: skills-response-templates - - - name: Configure Git user - run: | - git config user.name github-actions[bot] - git config user.email github-actions[bot]@users.noreply.github.com - - - name: Build message - congratulations - id: build-message-congratulations - uses: skills/action-text-variables@v1 - with: - template-file: skills-response-templates/readme/congratulations.md - template-vars: | - login=${{ github.actor }} - - - name: Update README - congratulations - run: | - # Add "Congratulations" to the start of the README - orig_readme=$(cat README.md) - new_readme="${{ steps.build-message-congratulations.outputs.updated-text }} $orig_readme" - - # Update file and push - echo "$new_readme" > README.md - git add README.md - git commit --message="Congratulations!🎉" - git push - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Build message - exercise finished - id: build-finish-message - uses: skills/action-text-variables@v1 - with: - template-file: skills-response-templates/step-feedback/lesson-finished.md - template-vars: | - login=${{ github.actor }} - repo_full_name=${{ github.repository }} - - - name: Create comment - exercise finished - run: | - gh issue comment "$ISSUE_URL" \ - --body "$ISSUE_BODY" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_BODY: ${{ steps.build-finish-message.outputs.updated-text }} - - - name: Close issue - run: gh issue close "$ISSUE_URL" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Disable current workflow - run: gh workflow disable "${{github.workflow}}" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}