diff --git a/README.md b/README.md index f0bcb6e..03fd148 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ - [Starting an exercise](#starting-an-exercise) - [Finding an exercise](#finding-an-exercise) - [📋 Markdown Templates](#-markdown-templates) + - [Using with GrantBirki/comment for issue comments](#using-with-grantbirkicomment-for-issue-comments) + - [Using with action-text-variables for file updates](#using-with-action-text-variables-for-file-updates) - [Notable Resources](#notable-resources) ## Purpose @@ -70,7 +72,32 @@ steps: cat exercise-toolkit/markdown-templates/step-feedback/checking-work.md ``` -Markdown templates are often used together with [skills/action-text-variables](https://github.com/skills/action-text-variables) GitHub Action +#### Using with GrantBirki/comment for issue comments + +Templates are often used with [GrantBirki/comment](https://github.com/GrantBirki/comment) to create dynamic comments on issues or pull requests: + +```yaml +steps: + - name: Get markdown templates + uses: actions/checkout@v4 + with: + repository: skills/exercise-toolkit + path: exercise-toolkit + ref: + + - name: Create comment - step finished + uses: GrantBirki/comment@v2.1.1 + with: + file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md + issue-number: ${{ env.ISSUE_NUMBER }} + repository: ${{ env.ISSUE_REPOSITORY }} + vars: | + next_step_number: 2 +``` + +#### Using with action-text-variables for file updates + +Markdown templates can also be used with [skills/action-text-variables](https://github.com/skills/action-text-variables) to generate dynamic content for any purpose, e.g updating a file. ```yaml steps: @@ -81,18 +108,20 @@ steps: path: exercise-toolkit ref: - - name: Build message - congratulations - id: build-message-congratulations - uses: skills/action-text-variables@v2 + - name: Build README from template + id: build-readme + uses: skills/action-text-variables@v3 with: - template-file: exercise-toolkit/markdown-templates/readme/congratulations.md + template-file: exercise-toolkit/markdown-templates/readme/exercise-started.md template-vars: | + title: ${{ inputs.exercise-title }} login: ${{ github.actor }} + issue_url: ${{ needs.create_exercise.outputs.issue-url }} - - name: Echo updated text - run: echo "$UPDATED_TEXT" + - name: Update README file + run: echo "$README_CONTENT" > README.md env: - UPDATED_TEXT: ${{ steps.build-message-congratulations.outputs.updated-text }} + README_CONTENT: ${{ steps.build-readme.outputs.updated-text }} ``` ## Notable Resources @@ -101,4 +130,5 @@ These GitHub Actions are particularly useful when creating GitHub Skills Exercis - **[skills/action-text-variables](https://github.com/skills/action-text-variables)**: Replace variables in template files with dynamic content - **[skills/action-keyphrase-checker](https://github.com/skills/action-keyphrase-checker)**: Verify if specific keyphrases exist in files or content +- **[GrantBirki/comment](https://github.com/GrantBirki/comment)**: Create comments on GitHub issues or pull requests with support for Nunjucks templating diff --git a/markdown-templates/README.md b/markdown-templates/README.md index ec18347..6c4f390 100644 --- a/markdown-templates/README.md +++ b/markdown-templates/README.md @@ -9,7 +9,9 @@ A collection of templates for use in Skills exercises. ## Template Variables -Several templates contain [mustache style variables](https://mustache.github.io/mustache.5.html). They are intended for use with the [skills/action-text-variables](https://github.com/skills/action-text-variables) GitHub Action, which supports full mustache templating. +Several templates contain [Nunjucks](https://mozilla.github.io/nunjucks/) style variable templating. They are intended for use with the [skills/action-text-variables](https://github.com/skills/action-text-variables) or [GrantBirki/comment](https://github.com/GrantBirki/comment) GitHub Actions, both of which support full Nunjucks templating. + + ### Example @@ -27,5 +29,10 @@ Hello {{ login }}, nice to meet you! } ``` +#### yaml input +```yaml +login: "${{ github.actor }}" +``` + > [!TIP] -> See [mustache syntax](https://mustache.github.io/mustache.5.html) for all capabilities like iteration and if/then logic. +> See [Nunjucks templating documentation](https://mozilla.github.io/nunjucks/templating.html) for all capabilities like iteration, conditionals, and more.