|
| 1 | +name: Finish Exercise Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + issue-url: |
| 7 | + description: "The URL of the issue to update and close" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + update_readme: |
| 13 | + name: Update README with congratulations |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: ${{ github.event.repository.default_branch }} |
| 21 | + |
| 22 | + - name: Get response templates |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + repository: skills/response-templates |
| 26 | + path: skills-response-templates |
| 27 | + |
| 28 | + - name: Build message - congratulations |
| 29 | + id: build-message-congratulations |
| 30 | + uses: skills/action-text-variables@v1 |
| 31 | + with: |
| 32 | + template-file: skills-response-templates/readme/congratulations.md |
| 33 | + template-vars: | |
| 34 | + login=${{ github.actor }} |
| 35 | +
|
| 36 | + - name: Update README - congratulations |
| 37 | + run: | |
| 38 | + # Add "Congratulations" to the start of the README |
| 39 | + orig_readme=$(cat README.md) |
| 40 | + new_readme="$CONTRATULATIONS_TEXT $orig_readme" |
| 41 | + echo "$new_readme" > README.md |
| 42 | + env: |
| 43 | + CONTRATULATIONS_TEXT: ${{ steps.build-message-congratulations.outputs.updated-text }} |
| 44 | + |
| 45 | + - name: Update README - congratulations |
| 46 | + uses: EndBug/add-and-commit@v9 |
| 47 | + with: |
| 48 | + add: "README.md" |
| 49 | + message: "Congratulations!🎉" |
| 50 | + default_author: github_actions |
| 51 | + |
| 52 | + finish_issue: |
| 53 | + name: Comment and close issue |
| 54 | + runs-on: ubuntu-latest |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Get response templates |
| 58 | + uses: actions/checkout@v4 |
| 59 | + with: |
| 60 | + repository: skills/response-templates |
| 61 | + path: skills-response-templates |
| 62 | + |
| 63 | + - name: Build message - exercise finished |
| 64 | + id: build-finish-message |
| 65 | + uses: skills/action-text-variables@v1 |
| 66 | + with: |
| 67 | + template-file: skills-response-templates/step-feedback/exercise-finished.md |
| 68 | + template-vars: | |
| 69 | + login=${{ github.actor }} |
| 70 | + repo_full_name=${{ github.repository }} |
| 71 | +
|
| 72 | + - name: Create comment - exercise finished |
| 73 | + run: | |
| 74 | + gh issue comment "${{ inputs.issue-url }}" \ |
| 75 | + --body "${{ steps.build-finish-message.outputs.updated-text }}" |
| 76 | + env: |
| 77 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + |
| 79 | + - name: Close issue |
| 80 | + run: gh issue close "${{ inputs.issue-url }}" |
| 81 | + env: |
| 82 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments