This repository was archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
This repository was archived by the owner on May 2, 2024. It is now read-only.
Setting points via other actions #52
Copy link
Copy link
Open
Description
This is not a feature request, merely a comment to document what seems like undocumented API.
I found I was able to set the "points" manually (instead of actually using education/autograding) via the following script:
- uses: actions/github-script@v6
with:
script: |
// derived from https://github.com/education/autograding/blob/1d058ce58864938499105ab5cd1c941651ce7e27/src/output.ts
// Fetch the workflow run
const workflowRunResponse = await github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
})
const checkSuiteUrl = workflowRunResponse.data.check_suite_url
const checkSuiteId = parseInt(checkSuiteUrl.match(/[0-9]+$/)[0], 10)
const checkRunsResponse = await github.rest.checks.listForSuite({
owner: context.repo.owner,
repo: context.repo.repo,
check_name: 'Autograding',
check_suite_id: checkSuiteId,
})
const checkRun = checkRunsResponse.data.total_count === 1 && checkRunsResponse.data.check_runs[0]
if (!checkRun) return;
// Update the checkrun, we'll assign the title, summary and text even though we expect
// the title and summary to be overwritten by GitHub Actions (they are required in this call)
// We'll also store the total in an annotation to future-proof
const text = "Points 11/10";
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: checkRun.id,
output: {
title: 'Autograding',
summary: text,
text: text,
annotations: [
{
// Using the `.github` path is what GitHub Actions does
path: '.github',
start_line: 1,
end_line: 1,
annotation_level: 'notice',
message: text,
title: 'Autograding complete',
},
],
},
})Note this makes it possible to accumulate points in other ways, such as using them to indicate the (non-negative integer) result of an optimization problem.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels