Exercise: Getting Started with GitHub Copilot #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Step 3b # Copilot Agent Mode | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| contents: read | |
| actions: write | |
| issues: write | |
| env: | |
| # Keywords required in the issue comment to allow this workflow to run | |
| REQUIRED_ISSUE_COMMENT_KEYWORDS: "@professortocat,Agent" | |
| STEP_3B_FILE: ".github/steps/3b-copilot-agent-mode.md" | |
| jobs: | |
| required_issue_comment_keywords: | |
| name: Check issue comment text for required keywords | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Stop early if missing the expected keywords, case insensitive | |
| shell: bash | |
| run: | | |
| required_keywords=(${REQUIRED_ISSUE_COMMENT_KEYWORDS//,/ }) | |
| comment_body_lower=$(echo "$COMMENT_BODY" | tr '[:upper:]' '[:lower:]') | |
| for keyword in "${required_keywords[@]}"; do | |
| keyword_lower=$(echo "$keyword" | tr '[:upper:]' '[:lower:]') | |
| if [[ ! "$comment_body_lower" =~ $keyword_lower ]]; then | |
| exit 1 | |
| fi | |
| done | |
| env: | |
| COMMENT_BODY: ${{ github.event.comment.body }} | |
| find_exercise: | |
| name: Find Exercise Issue | |
| uses: skills/exercise-toolkit/.github/workflows/[email protected] | |
| post_step_3b_content: | |
| name: Post step 3b content | |
| needs: [find_exercise, required_issue_comment_keywords] | |
| runs-on: ubuntu-latest | |
| env: | |
| ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create comment - add step content | |
| run: | | |
| gh issue comment "$ISSUE_URL" \ | |
| --body-file "$STEP_3B_FILE" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Disable current workflow | |
| run: | | |
| gh workflow disable "Step 3b" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |