-
Notifications
You must be signed in to change notification settings - Fork 1.2k
44 lines (41 loc) · 1.48 KB
/
new_examples_links_in_table_of_content.yml
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
name: All new examples are linked in the README
on:
pull_request:
branches: [ main ]
jobs:
new-example-links-in-examples-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get added files
run: |
git fetch origin main
git diff --name-status origin/main HEAD | grep ^A | cut -f2- > new_files.txt
echo "Added Files:"
cat new_files.txt | sed 's/^/ - /'
- name: Check for new example files
run: |
if grep "examples/" new_files.txt; then
grep '^examples/' new_files.txt > new_example_files.txt
echo "Found new file(s) in examples/:"
cat new_example_files.txt | sed 's/^/ - /'
else
echo "No new files found in examples/"
fi
- name: Check README links
run: |
if [[ -f new_example_files.txt ]]; then
all_linked=true
while IFS= read -r file; do
if ! grep -q "$file" examples/README.md; then
if ! grep -q "${file/examples\//](}" examples/README.md; then
all_linked=false
echo "Link to '$file' not found in README.md"
echo "::warning file=$file::Link to '$file' not found in examples/README.md, please add one in the table of content"
fi
fi
done < new_example_files.txt
if ! $all_linked; then
exit 1
fi
fi