Files
slsDetectorPackage/.github/workflows/pr_synchronize_trigger.yaml
T
maliakal_d 352627f9a4
Build on RHEL9 docker image / build (push) Successful in 4m35s
Build on RHEL8 docker image / build (push) Successful in 5m10s
Run Simulator Tests on local RHEL9 / build (push) Successful in 20m5s
Run Simulator Tests on local RHEL8 / build (push) Successful in 23m30s
trigger is just for code sync
2026-08-28 10:45:59 +02:00

139 lines
3.7 KiB
YAML

# This workflow is triggered when a PR is synchronized.
# It checks the latest PR Validation result for the PR.
# If PR Validation has not completed or was unsuccessful, this workflow fails.
# If PR Validation succeeded, it calls the detector label workflow.
name: PR Synchronize Trigger
on:
pull_request:
types:
- synchronize
permissions:
actions: read
pull-requests: read
jobs:
check-validation:
name: Check PR Validation
runs-on: ubuntu-latest
outputs:
should_run_detector_labels: ${{ steps.check.outputs.should_run_detector_labels }}
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 recent workflow runs for PR Validation.
*/
const { data } =
await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
event: 'pull_request',
per_page: 100
});
/*
* Find PR Validation runs associated with this PR.
*/
const validationRuns = data.workflow_runs.filter(run =>
run.name === validationWorkflowName &&
run.pull_requests?.some(
pr => pr.number === prNumber
)
);
/*
* No PR Validation run means 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.`
);
core.setOutput(
'should_run_detector_labels',
'true'
);
detector-labels:
name: Detect detector labels on synchronize
needs: check-validation
if: >
${{
needs.check-validation.outputs.should_run_detector_labels == 'true'
}}
uses: ./.github/workflows/pr_detector_labels.yaml
with:
pr_number: ${{ github.event.pull_request.number }}
permissions:
pull-requests: write
issues: read