diff --git a/.github/workflows/post-step-content.yml b/.github/workflows/post-step-content.yml new file mode 100644 index 0000000..e69de29 diff --git a/actions/post-step-content/README.md b/actions/post-step-content/README.md new file mode 100644 index 0000000..f954695 --- /dev/null +++ b/actions/post-step-content/README.md @@ -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/post-step-content@v0.5.0 + 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/post-step-content@v0.5.0 + 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/post-step-content@v0.5.0 + 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. diff --git a/actions/post-step-content/action.yml b/actions/post-step-content/action.yml new file mode 100644 index 0000000..776d84e --- /dev/null +++ b/actions/post-step-content/action.yml @@ -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 }}