mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-09-03 14:10:44 +02:00
Merge branch 'dev/pr_automation_2' into dev/test_pr_automation_2
This commit is contained in:
@@ -16,118 +16,6 @@ permissions:
|
||||
issues: read
|
||||
|
||||
jobs:
|
||||
check-validation:
|
||||
name: Check PR Validation
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check PR Validation result
|
||||
id: check
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const prNumber =
|
||||
context.payload.pull_request.number;
|
||||
|
||||
const validationWorkflowName =
|
||||
'PR Validation';
|
||||
|
||||
|
||||
/*
|
||||
* Get the current PR.
|
||||
*/
|
||||
const { data: pr } =
|
||||
await github.rest.pulls.get({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber
|
||||
});
|
||||
|
||||
const headBranch = pr.head.ref;
|
||||
|
||||
core.info(
|
||||
`Looking for PR Validation runs on branch "${headBranch}".`
|
||||
);
|
||||
|
||||
/*
|
||||
* Get PR Validation workflow runs for this branch.
|
||||
*/
|
||||
const runs = await github.paginate(
|
||||
github.rest.actions.listWorkflowRunsForRepo,
|
||||
{
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
event: 'pull_request',
|
||||
branch: headBranch,
|
||||
per_page: 100
|
||||
}
|
||||
);
|
||||
|
||||
/*
|
||||
* Keep only PR Validation runs.
|
||||
*/
|
||||
const validationRuns = runs.filter(
|
||||
run => run.name === validationWorkflowName
|
||||
);
|
||||
|
||||
/*
|
||||
* Validation has not been performed for this PR.
|
||||
*/
|
||||
if (validationRuns.length === 0) {
|
||||
core.setFailed(
|
||||
`No PR Validation run found for PR #${prNumber}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the most recent PR Validation run.
|
||||
*/
|
||||
const validationRun = validationRuns.sort(
|
||||
(a, b) =>
|
||||
new Date(b.created_at) -
|
||||
new Date(a.created_at)
|
||||
)[0];
|
||||
|
||||
core.info(
|
||||
`Latest PR Validation run: ${validationRun.id}`
|
||||
);
|
||||
|
||||
core.info(
|
||||
`Status: ${validationRun.status}`
|
||||
);
|
||||
|
||||
core.info(
|
||||
`Conclusion: ${validationRun.conclusion}`
|
||||
);
|
||||
|
||||
/*
|
||||
* PR Validation must have completed.
|
||||
*/
|
||||
if (validationRun.status !== 'completed') {
|
||||
core.setFailed(
|
||||
`PR Validation for PR #${prNumber} has not completed. Current status: ${validationRun.status}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* PR Validation must have succeeded.
|
||||
*/
|
||||
if (validationRun.conclusion !== 'success') {
|
||||
core.setFailed(
|
||||
`PR Validation for PR #${prNumber} did not succeed. Conclusion: ${validationRun.conclusion}.`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* PR Validation succeeded.
|
||||
*/
|
||||
core.info(
|
||||
`PR Validation for PR #${prNumber} succeeded. Running detector labels.`
|
||||
);
|
||||
|
||||
detector-labels:
|
||||
name: Detect detector labels
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
Reference in New Issue
Block a user