mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-25 14:14:14 +09:00
Raise the OpenSSF Scorecard Token-Permissions and Pinned-Dependencies checks (both currently 0/10) ahead of CNCF Incubation due diligence: - Declare a top-level read-only default (permissions: contents: read) in every workflow, plus an explicit per-job permissions: block that grants only the writes that job actually needs. Workflows that previously held write scopes at the workflow level (backport, pr-labeler, pr-size, stale) now hold them at job level instead. - Pin every GitHub-owned and third-party action to a full commit SHA with a version comment. scorecard.yml was already pinned in #2721. No triggers, job graph, or step logic change; only token scopes and action refs. Self-hosted release jobs keep the exact write scopes they already declared. Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com> Assisted-By: Claude <noreply@anthropic.com>
83 lines
2.6 KiB
YAML
83 lines
2.6 KiB
YAML
name: Retest
|
|
|
|
on:
|
|
issue_comment:
|
|
types: [created]
|
|
|
|
# Top-level token defaults to read-only; jobs request the minimum extra scopes.
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
retest:
|
|
name: Retest PR
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
github.event.issue.pull_request &&
|
|
contains(github.event.comment.body, '/retest')
|
|
permissions:
|
|
actions: write
|
|
pull-requests: read
|
|
|
|
steps:
|
|
- name: Rerun from Prepare environment
|
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
|
with:
|
|
script: |
|
|
const prNumber = context.issue.number;
|
|
|
|
// Get the PR to find the head SHA
|
|
const pr = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: prNumber
|
|
});
|
|
|
|
// Find the latest workflow run for this PR
|
|
const runs = await github.rest.actions.listWorkflowRuns({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
workflow_id: 'pull-requests.yaml',
|
|
head_sha: pr.data.head.sha
|
|
});
|
|
|
|
if (runs.data.workflow_runs.length === 0) {
|
|
core.setFailed('No workflow runs found for this PR');
|
|
return;
|
|
}
|
|
|
|
const latestRun = runs.data.workflow_runs[0];
|
|
console.log(`Found workflow run: ${latestRun.id} (${latestRun.status})`);
|
|
|
|
// Check if workflow is waiting for approval (fork PRs)
|
|
if (latestRun.conclusion === 'action_required') {
|
|
core.setFailed('Workflow is waiting for approval. A maintainer must approve the workflow first.');
|
|
return;
|
|
}
|
|
|
|
// Get jobs for this run
|
|
const jobs = await github.rest.actions.listJobsForWorkflowRun({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: latestRun.id
|
|
});
|
|
|
|
// Find "Prepare environment" job
|
|
const prepareJob = jobs.data.jobs.find(j => j.name === 'Prepare environment');
|
|
|
|
if (!prepareJob) {
|
|
core.setFailed('Could not find "Prepare environment" job');
|
|
return;
|
|
}
|
|
|
|
console.log(`Found job: ${prepareJob.name} (id: ${prepareJob.id}, status: ${prepareJob.status})`);
|
|
|
|
// Rerun the job
|
|
await github.rest.actions.reRunJobForWorkflowRun({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
job_id: prepareJob.id
|
|
});
|
|
|
|
console.log(`✅ Triggered rerun of job "${prepareJob.name}" (${prepareJob.id})`);
|