Skip to content
Merged
Show file tree
Hide file tree
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
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: <git-tag>

- name: Create comment - step finished
uses: GrantBirki/[email protected]
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:
Expand All @@ -81,18 +108,20 @@ steps:
path: exercise-toolkit
ref: <git-tag>

- 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
Expand All @@ -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

11 changes: 9 additions & 2 deletions markdown-templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.