Skip to content

Manage integration check #36

Manage integration check

Manage integration check #36

name: Manage integration check
on:
workflow_run:
workflows: ["Integration tests"]
jobs:
create-check:
runs-on: ubuntu-latest
outputs:
check_id: ${{ steps.create-check.outputs.result }}
steps:
- name: Create check
uses: actions/github-script@v6
id: create-check
if: ${{ context.payload.action == 'requested' || context.payload.action == 'in_progress' }}

Check failure on line 16 in .github/workflows/manage-integration-check.yml

View workflow run for this annotation

GitHub Actions / Manage integration check

Invalid workflow file

The workflow is not valid. .github/workflows/manage-integration-check.yml (Line: 16, Col: 13): Unrecognized named-value: 'context'. Located at position 1 within expression: context.payload.action == 'requested' || context.payload.action == 'in_progress' .github/workflows/manage-integration-check.yml (Line: 36, Col: 13): Unrecognized named-value: 'context'. Located at position 1 within expression: context.payload.action == 'completed'
with:
script: |
const head_sha = context.payload.workflow_run.head_sha;
const check = await github.rest.checks.create({
...context.repo,
head_sha,
name: "integration-test-result",
status: "in_progress",
output: {
title: "Integration Test Aggregate Result",
summary: `Synthetic check capturing the result of the <a href="${context.workflow_run.html_url}">integration-test workflow run</a>`,
}
});
return check.data.id;
update-check:
runs-on: ubuntu-latest
steps:
- name: Update check result
uses: actions/github-script@v6
if: ${{ context.payload.action == 'completed' }}
with:
script: |
// Update the check run
const head_sha = context.payload.workflow_run.head_sha;
const runs = await github.paginate(github.rest.checks.listForRef, {
...context.repo,
ref: head_sha,
check_name: "integration-test-result",
})
core.debug(`integration-test-result check runs: ${JSON.stringify(runs, null, 2)}`);
const checkId = runs.sort((a, b) => Date.parse(b.started_at) - Date.parse(a.started_at))[0];
if (!checkId) {
core.setFailed(`No integration-test-result check found for commit ${head_sha}`);
return;
}
await github.checks.update({
...context.repo
check_run_id: checkId,
status: "completed",
conclusion: context.payload.workflow_run.conclusion,
});