mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-10-15 21:30:26 +02:00
* user should be allowed to manually remove detector label * automation script fix
211 lines
5.8 KiB
YAML
211 lines
5.8 KiB
YAML
# This workflow is triggered when opening/reopening PR, editing the PR description or changing labels. It ignores unrelated label changes. It runs PR type validation and if it succeeds, it runs PR milestone, release notes, file version and detector labels workflow in parallel.
|
|
name: PR Edit Trigger
|
|
|
|
on:
|
|
pull_request:
|
|
types:
|
|
- opened
|
|
- reopened
|
|
- edited
|
|
- labeled
|
|
- unlabeled
|
|
|
|
permissions:
|
|
pull-requests: write
|
|
contents: read
|
|
models: read
|
|
|
|
jobs:
|
|
check-pr-trigger:
|
|
name: Check PR Trigger
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
require_validation: ${{ steps.check.outputs.require_validation }}
|
|
file_label_change: ${{ steps.check.outputs.file_label_change }}
|
|
detector_label_change: ${{ steps.check.outputs.detector_label_change }}
|
|
pr_edited: ${{ steps.check.outputs.pr_edited }}
|
|
|
|
steps:
|
|
- name: Check PR Trigger
|
|
id: check
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
let requireValidation = true;
|
|
let fileLabelChange = false;
|
|
let detectorLabelChange = false;
|
|
|
|
/*
|
|
* If triggered by label change, ignore unrelated labels.
|
|
*/
|
|
const action = context.payload.action;
|
|
const prEdited = action === 'edited';
|
|
|
|
if (action === 'labeled' || action === 'unlabeled') {
|
|
const changedLabel = context.payload.label?.name;
|
|
core.info(
|
|
`Changed Label: ${changedLabel}`
|
|
);
|
|
|
|
const relevantLabels = [
|
|
'Feature',
|
|
'Bug Fix',
|
|
'Infrastructure',
|
|
'Breaking API'
|
|
];
|
|
|
|
if (!relevantLabels.includes(changedLabel)) {
|
|
requireValidation = false;
|
|
}
|
|
|
|
// File Major requires Breaking API label
|
|
const fileLabels = [
|
|
'File Major',
|
|
'File Minor',
|
|
'Breaking API'
|
|
];
|
|
if (fileLabels.includes(changedLabel)) {
|
|
fileLabelChange = true;
|
|
}
|
|
|
|
const detectorLabels = [
|
|
'Ctb',
|
|
'Eiger',
|
|
'Moench',
|
|
'Mythen3',
|
|
'Jungfrau',
|
|
'Gotthard2',
|
|
'Matterhorn',
|
|
'Xilinx_ctb'
|
|
];
|
|
if (detectorLabels.includes(changedLabel)) {
|
|
detectorLabelChange = true;
|
|
}
|
|
}
|
|
|
|
core.setOutput(
|
|
'require_validation',
|
|
requireValidation.toString()
|
|
);
|
|
core.setOutput(
|
|
'file_label_change',
|
|
fileLabelChange.toString()
|
|
);
|
|
core.setOutput(
|
|
'detector_label_change',
|
|
detectorLabelChange.toString()
|
|
);
|
|
core.setOutput(
|
|
'pr_edited',
|
|
prEdited.toString()
|
|
);
|
|
|
|
if (requireValidation) {
|
|
core.info('PR type validation: Required.');
|
|
} else {
|
|
core.info('PR type validation: Not required - Unrelated label.');
|
|
}
|
|
if (fileLabelChange) {
|
|
core.info('File label or Breaking API: Changed.');
|
|
} else {
|
|
core.info('File label or Breaking API: No Change.');
|
|
}
|
|
if (detectorLabelChange) {
|
|
core.info('Detector label: Changed.');
|
|
} else {
|
|
core.info('Detector label: No Change.');
|
|
}
|
|
|
|
validate-pr-type:
|
|
needs: check-pr-trigger
|
|
if: ${{ needs.check-pr-trigger.outputs.require_validation == 'true' }}
|
|
uses: ./.github/workflows/pr_type_validation.yaml
|
|
with:
|
|
pr_number: ${{ github.event.pull_request.number }}
|
|
permissions:
|
|
pull-requests: write
|
|
contents: read
|
|
|
|
milestone:
|
|
needs:
|
|
- check-pr-trigger
|
|
- validate-pr-type
|
|
if: >-
|
|
${{
|
|
always() &&
|
|
(
|
|
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
|
needs.validate-pr-type.result == 'success'
|
|
)
|
|
}}
|
|
uses: ./.github/workflows/pr_milestone.yaml
|
|
with:
|
|
pr_number: ${{ github.event.pull_request.number }}
|
|
permissions:
|
|
pull-requests: write
|
|
contents: read
|
|
|
|
detector-labels:
|
|
needs:
|
|
- check-pr-trigger
|
|
- validate-pr-type
|
|
if: >-
|
|
${{
|
|
always() &&
|
|
(
|
|
needs.check-pr-trigger.outputs.detector_label_change == 'false' &&
|
|
(
|
|
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
|
needs.validate-pr-type.result == 'success'
|
|
)
|
|
)
|
|
}}
|
|
uses: ./.github/workflows/pr_detector_labels.yaml
|
|
with:
|
|
pr_number: ${{ github.event.pull_request.number }}
|
|
permissions:
|
|
pull-requests: write
|
|
issues: read
|
|
|
|
release-notes:
|
|
needs:
|
|
- check-pr-trigger
|
|
- detector-labels
|
|
if: >-
|
|
${{
|
|
always() &&
|
|
(
|
|
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
|
needs.detector-labels.result == 'success'
|
|
)
|
|
}}
|
|
uses: ./.github/workflows/pr_release_notes.yaml
|
|
with:
|
|
pr_number: ${{ github.event.pull_request.number }}
|
|
permissions:
|
|
pull-requests: read
|
|
contents: read
|
|
|
|
file-version:
|
|
needs:
|
|
- check-pr-trigger
|
|
- validate-pr-type
|
|
if: >-
|
|
${{
|
|
always() &&
|
|
(
|
|
needs.check-pr-trigger.outputs.file_label_change == 'true'
|
|
) ||
|
|
(
|
|
needs.check-pr-trigger.outputs.require_validation == 'false' ||
|
|
needs.validate-pr-type.result == 'success'
|
|
)
|
|
}}
|
|
uses: ./.github/workflows/pr_file_version.yaml
|
|
with:
|
|
pr_number: ${{ github.event.pull_request.number }}
|
|
permissions:
|
|
pull-requests: write
|
|
contents: read
|