Skip to content

Reorg samples

Reorg samples #5

Workflow file for this run

name: Check Samples
on:
pull_request:
paths:
- 'samples/**'
- '.github/workflows/check-sample.yml'
jobs:
check_samples:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Make script executable
run: chmod +x ./scripts/check-sample-files.sh
- name: Run Checks
id: checks
run: |
checklist=$(./scripts/check-sample-files.sh | base64)
echo "checklist=$checklist" >> $GITHUB_ENV
- name: Add checklist to PR description
uses: actions/github-script@v5
env:
CHECKLIST: ${{ env.checklist }}
with:
script: |
const pr_number = context.issue.number;
const checklist = Buffer.from(process.env.CHECKLIST, 'base64').toString('utf8');
const marker = '--- CHECKLIST ---';
// Get the current PR
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr_number
});
let newBody;
const body = pullRequest.body;
const markerIndex = body.indexOf(marker);
if (markerIndex !== -1) {
// Replace the content below the marker
newBody = body.substring(0, markerIndex + marker.length) + "\n" + checklist;
} else {
// Append the checklist if the marker doesn't exist
newBody = body + "\n" + marker + "\n" + checklist;
}
// Update the PR description
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr_number,
body: newBody
});