Skip to content

Commit c4070c4

Browse files
authored
chore: synced file(s) with ecmwf/reusable-workflows (ecmwf#325)
synced local file(s) with [ecmwf/reusable-workflows](https://github.com/ecmwf/reusable-workflows). <details> <summary>Changed files</summary> <ul> <li>synced local directory <code>./</code> with remote directory <code>sync-files/anemoi/all/</code></li> </ul> </details> --- This PR was created automatically by the [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) workflow run [#17737613242](https://github.com/ecmwf/reusable-workflows/actions/runs/17737613242)
1 parent d475199 commit c4070c4

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/pr-label-ats.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# This workflow checks that the appropriate ATS labels are applied to a pull request:
2+
# - "ATS Approval Not Needed": pass
3+
# - "ATS Approved": pass
4+
# - "ATS Approval Needed": fail
5+
# - Missing ATS label: fail
6+
7+
name: "[PR] ATS labels"
8+
9+
on:
10+
pull_request:
11+
types:
12+
- opened
13+
- edited
14+
- reopened
15+
- labeled
16+
- unlabeled
17+
- synchronize
18+
19+
permissions:
20+
pull-requests: read
21+
22+
jobs:
23+
check:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Get PR details
27+
uses: actions/github-script@v7
28+
id: check-pr
29+
with:
30+
script: |
31+
const pr = await github.rest.pulls.get({
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
pull_number: context.payload.pull_request.number,
35+
});
36+
const labels = pr.data.labels.map(label => label.name);
37+
core.setOutput('labels', JSON.stringify(labels));
38+
core.setOutput('author', context.payload.pull_request.user.login);
39+
40+
- name: Evaluate ATS labels
41+
run: |
42+
AUTHOR='${{ steps.check-pr.outputs.author }}'
43+
if [ "$AUTHOR" == "DeployDuck" ] || [ "$AUTHOR" == "pre-commit-ci[bot]" ]; then
44+
echo "Bot PR, skipping."
45+
exit 0
46+
fi
47+
LABELS=$(echo '${{ steps.check-pr.outputs.labels }}' | jq -r '.[]')
48+
echo "Labels found:"
49+
echo -e "$LABELS\n"
50+
echo "Result:"
51+
if echo "$LABELS" | grep -qi "ATS approval not needed"; then
52+
echo "ATS approval not needed. Passing."
53+
EXIT_CODE=0
54+
elif echo "$LABELS" | grep -qi "ATS approved"; then
55+
echo "ATS Approved. Passing."
56+
EXIT_CODE=0
57+
elif echo "$LABELS" | grep -qi "ATS approval needed"; then
58+
echo "ATS Approval Needed. Failing."
59+
EXIT_CODE=1
60+
else
61+
echo "No ATS approval labels found. Please assign the appropriate ATS label. Failing."
62+
EXIT_CODE=1
63+
fi
64+
echo -e "\nFor more information on ATS labels, see:"
65+
echo "https://anemoi.readthedocs.io/en/latest/contributing/guidelines.html#labelling-guidelines"
66+
exit $EXIT_CODE

0 commit comments

Comments
 (0)