-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
84 lines (76 loc) · 2.62 KB
/
ci.yml
File metadata and controls
84 lines (76 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: CI
on:
pull_request:
branches: [master]
jobs:
readme-check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check README.md was not edited directly
id: readme
run: |
TRUSTED="mre jakubsacha"
AUTHOR="${{ github.event.pull_request.user.login }}"
for u in $TRUSTED; do
if [ "$AUTHOR" = "$u" ]; then
echo "trusted=true" >> "$GITHUB_OUTPUT"
exit 0
fi
done
if git diff --name-only origin/master...HEAD | grep -q "^README.md$"; then
echo "modified=true" >> "$GITHUB_OUTPUT"
fi
- name: Comment and fail on direct README edit
if: steps.readme.outputs.modified == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
gh api "repos/$REPO/issues/$PR/comments" \
-f body="README.md was edited directly. The README is generated from the YAML files in \`data/tools/\`. Please add or edit the corresponding file in \`data/tools/\` instead and do not touch README.md." \
--silent
echo "README.md must not be edited directly." >&2
exit 1
render:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Render list
id: render
run: |
make render-skip-deprecated 2>&1 | tee /tmp/render-output.txt
exit ${PIPESTATUS[0]}
- name: Comment render error on failure
if: failure() && steps.render.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
OUTPUT=$(grep -E "^Error" /tmp/render-output.txt | head -20)
{
echo "The render step failed with the following error:"
echo ""
echo '```'
echo "$OUTPUT"
echo '```'
echo ""
echo "Please check your YAML file in \`data/tools/\` against the format used by other tools in that directory."
} > /tmp/render-comment.txt
gh api "repos/$REPO/issues/$PR/comments" \
-f body=@/tmp/render-comment.txt \
--silent