Skip to content

Commit 45edc80

Browse files
POC of reusing post next step content with a workflow or an action
1 parent 3627ef8 commit 45edc80

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

.github/workflows/post-step-content.yml

Whitespace-only changes.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Post Step Content Action
2+
3+
A composite action that posts step content to GitHub issues for GitHub Skills exercises.
4+
5+
## Usage
6+
7+
```yaml
8+
- name: Post step content
9+
uses: skills/exercise-toolkit/actions/[email protected]
10+
with:
11+
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
12+
step-content-file: ".github/steps/2-commit-a-file.md"
13+
```
14+
15+
## Inputs
16+
17+
| Input | Description | Required | Default |
18+
| ------------------- | ------------------------------------------------- | -------- | ------- |
19+
| `issue-url` | URL of the issue to post content to | ✅ | - |
20+
| `step-content-file` | Path to the markdown file containing step content | ✅ | - |
21+
| `template-vars` | Template variables in YAML or JSON format | ❌ | `""` |
22+
23+
## Examples
24+
25+
### Basic Usage
26+
27+
```yaml
28+
- uses: skills/exercise-toolkit/actions/[email protected]
29+
with:
30+
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
31+
step-content-file: ".github/steps/3-open-a-pull-request.md"
32+
```
33+
34+
### With Template Variables
35+
36+
```yaml
37+
- uses: skills/exercise-toolkit/actions/[email protected]
38+
with:
39+
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
40+
step-content-file: ".github/steps/step-finished-prepare-next-step.md"
41+
template-vars: |
42+
next_step_number: 4
43+
congratulations_message: "Great work!"
44+
```
45+
46+
### Using Development Version
47+
48+
```yaml
49+
- uses: skills/exercise-toolkit/actions/post-step-content@main
50+
with:
51+
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
52+
step-content-file: ".github/steps/x-review.md"
53+
```
54+
55+
## What This Action Does
56+
57+
1. **Checkout exercise-toolkit**: Gets the markdown templates
58+
2. **Process templates** (if template-vars provided): Uses `skills/action-text-variables` to process template variables
59+
3. **Post step completion message**: Adds a congratulatory comment indicating the step is finished
60+
4. **Post step content**: Adds the step content as an issue comment
61+
5. **Add progress comment**: Posts a "watching for progress" comment
62+
63+
## Requirements
64+
65+
- Requires `GITHUB_TOKEN` with `issues: write` permissions
66+
- The calling workflow must have checked out the repository to access step content files
67+
68+
## Development
69+
70+
This action is part of the GitHub Skills exercise-toolkit and is designed to standardize step content posting across all GitHub Skills exercises.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: "Post Step Content"
2+
description: "Posts step content to GitHub issue and manages workflow transitions"
3+
inputs:
4+
issue-url:
5+
description: "URL of the issue to post content to"
6+
required: true
7+
step-content-file:
8+
description: 'Path to the markdown file containing step content (e.g., ".github/steps/2-step.md")'
9+
required: true
10+
template-vars:
11+
description: "Template variables in YAML or JSON format"
12+
required: false
13+
default: ""
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
- name: Get response templates
19+
uses: actions/checkout@v4
20+
with:
21+
repository: skills/exercise-toolkit
22+
path: exercise-toolkit
23+
ref: main
24+
25+
- name: Build content from template
26+
id: build-content
27+
if: inputs.template-vars != ''
28+
uses: skills/action-text-variables@v2
29+
with:
30+
template-file: ${{ inputs.step-content-file }}
31+
template-vars: ${{ inputs.template-vars }}
32+
33+
- name: Create comment - step finished
34+
shell: bash
35+
run: |
36+
gh issue comment "${{ inputs.issue-url }}" \
37+
--body-file exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
41+
- name: Create comment - add step content
42+
shell: bash
43+
run: |
44+
if [ "${{ inputs.template-vars }}" != "" ]; then
45+
gh issue comment "${{ inputs.issue-url }}" \
46+
--body "${{ steps.build-content.outputs.updated-text }}"
47+
else
48+
gh issue comment "${{ inputs.issue-url }}" \
49+
--body-file "${{ inputs.step-content-file }}"
50+
fi
51+
env:
52+
GH_TOKEN: ${{ github.token }}
53+
54+
- name: Create comment - watching for progress
55+
shell: bash
56+
run: |
57+
gh issue comment "${{ inputs.issue-url }}" \
58+
--body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
59+
env:
60+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)