Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/finish-exercise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Finish Exercise Workflow

on:
workflow_call:
inputs:
issue-url:
description: "The URL of the issue to update and close"
required: true
type: string

jobs:
update_readme:
name: Update README with congratulations
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.repository.default_branch }}

- name: Get response templates
uses: actions/checkout@v4
with:
repository: skills/response-templates
path: skills-response-templates

- 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="$CONTRATULATIONS_TEXT $orig_readme"
echo "$new_readme" > README.md
env:
CONTRATULATIONS_TEXT: ${{ steps.build-message-congratulations.outputs.updated-text }}

- name: Update README - congratulations
uses: EndBug/add-and-commit@v9
with:
add: "README.md"
message: "Congratulations!🎉"
default_author: github_actions

finish_issue:
name: Comment and close issue
runs-on: ubuntu-latest

steps:
- name: Get response templates
uses: actions/checkout@v4
with:
repository: skills/response-templates
path: skills-response-templates

- name: Build message - exercise finished
id: build-finish-message
uses: skills/action-text-variables@v1
with:
template-file: skills-response-templates/step-feedback/exercise-finished.md
template-vars: |
login=${{ github.actor }}
repo_full_name=${{ github.repository }}

- name: Create comment - exercise finished
run: |
gh issue comment "${{ inputs.issue-url }}" \
--body "${{ steps.build-finish-message.outputs.updated-text }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Close issue
run: gh issue close "${{ inputs.issue-url }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}