skills-introduction-to-github

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

4-merge-your-pull-request.yml (2641B)


      1 name: Step 4 # Merge your pull request
      2 
      3 # Checks if the learner completed tasks for step 4.
      4 # - Triggers when the user merges the pull request.
      5 # - If all checks pass, the workflow is disabled so it doesn't run again. As such, workflow status badge will change to green.
      6 
      7 on:
      8   pull_request:
      9     branches:
     10       - main
     11     types:
     12       - closed
     13 
     14 permissions:
     15   contents: write
     16   actions: write
     17   issues: write
     18 
     19 env:
     20   REVIEW_FILE: ".github/steps/x-review.md"
     21 
     22 jobs:
     23   find_exercise:
     24     name: Find Exercise Issue
     25     uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.1.0
     26 
     27   check_step_work:
     28     name: Check step work
     29     needs: find_exercise
     30     runs-on: ubuntu-latest
     31     if: |
     32       !github.event.repository.is_template &&
     33       github.head_ref == 'my-first-branch' &&
     34       github.event.pull_request.merged == true
     35     env:
     36       ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
     37 
     38     steps:
     39       - name: Get response templates
     40         uses: actions/checkout@v4
     41         with:
     42           repository: skills/exercise-toolkit
     43           path: exercise-toolkit
     44           ref: v0.1.0
     45 
     46       - name: Nothing to check
     47         run: echo "The workflow was triggered, so it passes."
     48 
     49       - name: Update comment - step finished - final review next
     50         run: |
     51           gh issue comment "$ISSUE_URL" \
     52             --body-file exercise-toolkit/markdown-templates/step-feedback/lesson-review.md \
     53             --edit-last
     54         env:
     55           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     56 
     57   post_review_content:
     58     name: Post review content
     59     needs: [find_exercise, check_step_work]
     60     runs-on: ubuntu-latest
     61     if: |
     62       !github.event.repository.is_template
     63     env:
     64       ISSUE_URL: ${{ needs.find_exercise.outputs.issue-url }}
     65 
     66     steps:
     67       - name: Checkout
     68         uses: actions/checkout@v4
     69 
     70       - name: Create comment - add review content
     71         run: |
     72           gh issue comment "$ISSUE_URL" \
     73             --body-file ${{ env.REVIEW_FILE }}
     74         env:
     75           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     76 
     77   finish_exercise:
     78     name: Finish Exercise
     79     needs: [find_exercise, post_review_content]
     80     uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.1.0
     81     with:
     82       issue-url: ${{ needs.find_exercise.outputs.issue-url }}
     83 
     84 
     85   disable_workflow:
     86     name: Disable this workflow
     87     needs: [find_exercise, post_review_content]
     88     runs-on: ubuntu-latest
     89 
     90     steps:
     91       - name: Checkout
     92         uses: actions/checkout@v4
     93       - name: Disable current workflow
     94         run: gh workflow disable "${{github.workflow}}"
     95         env:
     96           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
     97