/
githubmirror
/
ydb-java-sdk
Обзор
Документация
Войти
/
githubmirror
/
ydb-java-sdk
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
.github/workflows/slo-report.yml
102 строки
4 KB
Alexandr Gorshenin
Revert "Use dev version of ydb-slo-action"
17 июл 2026, 13:34
Не верифицирован
17 июл 2026, 13:34
6ab4366
Код
Авторство
О чём код?
name: slo-report # Runs in the base-repo context (not the fork's), so it has the # pull-requests: write permission needed to publish reports and edit # labels — which fork-triggered SLO runs do not. on: workflow_run: workflows: ["SLO"] types: - completed jobs: publish-slo-report: # Only act on runs that actually executed to completion. A "skipped" # conclusion means the matrix was gated out (no "SLO" label) — nothing to # publish. A "cancelled" conclusion means the run was superseded mid-flight # (e.g. by `cancel-in-progress` when a new run started) — there is no real # report and the label must NOT be stripped, otherwise it gets removed long # before the actual workload finishes. Success/failure are genuine endings. if: >- github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' name: Publish YDB SLO Report runs-on: ubuntu-latest permissions: checks: write contents: read pull-requests: write steps: - name: Publish YDB SLO Report uses: ydb-platform/ydb-slo-action/report@v2 with: github_token: ${{ secrets.GITHUB_TOKEN }} github_run_id: ${{ github.event.workflow_run.id }} remove-slo-label: # Same gating as the report job: only consume the "SLO" label once a run has # genuinely finished (success/failure). Removing it on a "cancelled" run # would strip the label mid-flight when a run is superseded. if: >- github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' name: Remove SLO Label runs-on: ubuntu-latest permissions: pull-requests: write steps: - name: Remove SLO label from PR uses: actions/github-script@v7 with: script: | const workflowRun = context.payload.workflow_run; let pullRequestNumbers = []; // Same-repo PRs are listed directly in the workflow_run payload. // For fork PRs `pull_requests` is always empty, so resolve the PR // from the run's head branch + fork owner and disambiguate by the // head SHA. Without this the label is never removed on fork PRs. if (workflowRun.pull_requests?.length > 0) { pullRequestNumbers = workflowRun.pull_requests.map((pr) => pr.number); } else if (workflowRun.head_branch && workflowRun.head_repository?.owner?.login) { const head = `${workflowRun.head_repository.owner.login}:${workflowRun.head_branch}`; const { data: pulls } = await github.rest.pulls.list({ owner: context.repo.owner, repo: context.repo.repo, head, state: 'all', per_page: 100, }); const matched = workflowRun.head_sha ? pulls.filter((pr) => pr.head.sha === workflowRun.head_sha) : pulls; pullRequestNumbers = (matched.length > 0 ? matched : pulls).map((pr) => pr.number); if (pullRequestNumbers.length === 0) { console.log(`No pull requests found for head ${head}`); } else { console.log(`Resolved pull request(s) from head ${head}: #${pullRequestNumbers.join(', #')}`); } } else { console.log('No pull requests associated with this workflow run and unable to resolve head'); } for (const number of pullRequestNumbers) { try { await github.rest.issues.removeLabel({ owner: context.repo.owner, repo: context.repo.repo, issue_number: number, name: 'SLO', }); console.log(`Removed SLO label from PR #${number}`); } catch (error) { if (error.status === 404) { console.log(`SLO label not found on PR #${number}, skipping`); } else { throw error; } } }