Skip to content

step 1

step 1 #1

Workflow file for this run

name: Step 1
on:
push:
paths:
- ".vscode/mcp.json"
permissions:
contents: read
actions: write
issues: write
env:
STEP_2_FILE: ".github/steps/2-step.md"
jobs:
find_exercise:
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/[email protected]
create_issues:
name: Create issues
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
# TODO: replace with https://github.com/marketplace/actions/create-an-issue
- name: Create issues
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
async function createIssuesFromMarkdownFiles(dir, label) {
// Get list of markdown files
const files = fs.readdirSync(dir);
console.log(`Creating ${files.length} issues with '${label}' label from '${dir}' folder.`);
// Create the issue
for (const file of files) {
// Load the file content
const fullPath = path.join(dir, file);
const fileContent = fs.readFileSync(fullPath, 'utf8');
// Split the file content into title, body, and comments
const title = fileContent.split('\n')[0].replace('#', '').trim();
const body = fileContent.split('\n').slice(1).join('\n').split('----- COMMENTS -----')[0].trim();
let comments = fileContent.split('----- COMMENTS -----').slice(1).join('\n').trim().split('\n')
comments = comments.filter(comment => comment.trim() !== '');
// Log the content
// console.log(`\n\Title: ${title}`);
// console.log(`Body:\n${body}`);
// for (const comment of comments) {
// console.log(`Comment: '${comment.trim()}'`);
// }
// console.log(`\n`);
// Create the issue
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: [label],
});
// Add comments
for (const comment of comments) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.data.number,
body: comment,
});
}
console.log(`Created issue: ${title}, URL: ${issue.data.html_url} with ${comments.length} comments.`);
}
};
// Load issues from both folders
await createIssuesFromMarkdownFiles('.github/steps/1-step-issues/bug/', 'bug');
await createIssuesFromMarkdownFiles('.github/steps/1-step-issues/enhancement/', 'enhancement');
post_next_step_content:
name: Post next step content
needs: [find_exercise]
runs-on: ubuntu-latest
env:
ISSUE_REPOSITORY: ${{ github.repository }}
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Get response templates
uses: actions/checkout@v5
with:
repository: skills/exercise-toolkit
path: exercise-toolkit
ref: v0.7.0
- name: Create comment - step finished
uses: GrantBirki/[email protected]
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
vars: |
next_step_number: 2
- name: Create comment - add step content
uses: GrantBirki/[email protected]
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: ${{ env.STEP_2_FILE }}
vars: |
full_repo_name: ${{ github.repository }}
- name: Create comment - watching for progress
uses: GrantBirki/[email protected]
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
- name: Disable current workflow and enable next one
run: |
gh workflow disable "${{github.workflow}}"
gh workflow enable "Step 2"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}