Skip to content

Post next step reusable #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
Empty file.
70 changes: 70 additions & 0 deletions actions/post-step-content/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Post Step Content Action

A composite action that posts step content to GitHub issues for GitHub Skills exercises.

## Usage

```yaml
- name: Post step content
uses: skills/exercise-toolkit/actions/[email protected]
with:
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
step-content-file: ".github/steps/2-commit-a-file.md"
```

## Inputs

| Input | Description | Required | Default |
| ------------------- | ------------------------------------------------- | -------- | ------- |
| `issue-url` | URL of the issue to post content to | ✅ | - |
| `step-content-file` | Path to the markdown file containing step content | ✅ | - |
| `template-vars` | Template variables in YAML or JSON format | ❌ | `""` |

## Examples

### Basic Usage

```yaml
- uses: skills/exercise-toolkit/actions/[email protected]
with:
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
step-content-file: ".github/steps/3-open-a-pull-request.md"
```

### With Template Variables

```yaml
- uses: skills/exercise-toolkit/actions/[email protected]
with:
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
step-content-file: ".github/steps/step-finished-prepare-next-step.md"
template-vars: |
next_step_number: 4
congratulations_message: "Great work!"
```

### Using Development Version

```yaml
- uses: skills/exercise-toolkit/actions/post-step-content@main
with:
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
step-content-file: ".github/steps/x-review.md"
```

## What This Action Does

1. **Checkout exercise-toolkit**: Gets the markdown templates
2. **Process templates** (if template-vars provided): Uses `skills/action-text-variables` to process template variables
3. **Post step completion message**: Adds a congratulatory comment indicating the step is finished
4. **Post step content**: Adds the step content as an issue comment
5. **Add progress comment**: Posts a "watching for progress" comment

## Requirements

- Requires `GITHUB_TOKEN` with `issues: write` permissions
- The calling workflow must have checked out the repository to access step content files

## Development

This action is part of the GitHub Skills exercise-toolkit and is designed to standardize step content posting across all GitHub Skills exercises.
60 changes: 60 additions & 0 deletions actions/post-step-content/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Post Step Content"
description: "Posts step content to GitHub issue and manages workflow transitions"
inputs:
issue-url:
description: "URL of the issue to post content to"
required: true
step-content-file:
description: 'Path to the markdown file containing step content (e.g., ".github/steps/2-step.md")'
required: true
template-vars:
description: "Template variables in YAML or JSON format"
required: false
default: ""

runs:
using: "composite"
steps:
- name: Get response templates
uses: actions/checkout@v4
with:
repository: skills/exercise-toolkit
path: exercise-toolkit
ref: main

- name: Build content from template
id: build-content
if: inputs.template-vars != ''
uses: skills/action-text-variables@v2
with:
template-file: ${{ inputs.step-content-file }}
template-vars: ${{ inputs.template-vars }}

- name: Create comment - step finished
shell: bash
run: |
gh issue comment "${{ inputs.issue-url }}" \
--body-file exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
env:
GH_TOKEN: ${{ github.token }}

- name: Create comment - add step content
shell: bash
run: |
if [ "${{ inputs.template-vars }}" != "" ]; then
gh issue comment "${{ inputs.issue-url }}" \
--body "${{ steps.build-content.outputs.updated-text }}"
else
gh issue comment "${{ inputs.issue-url }}" \
--body-file "${{ inputs.step-content-file }}"
fi
env:
GH_TOKEN: ${{ github.token }}

- name: Create comment - watching for progress
shell: bash
run: |
gh issue comment "${{ inputs.issue-url }}" \
--body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
env:
GH_TOKEN: ${{ github.token }}