Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions .github/workflows/_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,44 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Mark lint run in progress
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const marker = '<!-- shared-workflows-ci-status -->';
const workflowUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number });
const existing = comments.find((comment) => comment.body?.includes(marker));
let previous = '';
if (existing) {
if (existing.body.includes('this comment will be updated when the run completes')) {
const match = existing.body.match(/<details><summary>Previous run output<\/summary>\n\n([\s\S]*)\n\n<\/details>\s*$/);
previous = match ? match[1].trim() : '';
} else {
previous = existing.body.replace(marker, '').trim();
}
}
const parts = [
marker,
'#### Shared Workflows CI',
'',
'Shared workflows CI is in progress; this comment will be updated when the run completes.',
'',
`[View the workflow run](${workflowUrl}).`,
];
if (previous) {
parts.push('', '<details><summary>Previous run output</summary>', '', previous, '', '</details>');
}
const body = parts.join('\n');
if (existing) {
await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body });
}

- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

Expand Down Expand Up @@ -47,13 +85,27 @@ jobs:
const maxLength = 12000;
const output = fs.existsSync('validation.log')
? fs.readFileSync('validation.log', 'utf8')
.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, '')
.replace(/\b(?:gh[pousr]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g, '***REDACTED***')
.replace(/````/g, '\\`\\`\\`\\`')
: 'No validation output was captured.';
const excerpt = output.length > maxLength ? output.slice(-maxLength) : output;
const status = failed ? 'failed' : 'passed';
const body = `${marker}\n## Shared workflows CI ${status}\n\n[View the workflow run](${workflowUrl}).\n\n#### Validation output (redacted, last ${maxLength} characters)\n\n\`\`\`\`text\n${excerpt}\n\`\`\`\``;
const body = [
marker,
'#### Shared Workflows CI',
'',
`Shared workflows CI ${status}.`,
'',
`[View the workflow run](${workflowUrl}).`,
'',
'<details><summary>View run output</summary>',
'',
'````text',
excerpt,
'````',
'',
'</details>',
].join('\n');
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down