-
Notifications
You must be signed in to change notification settings - Fork 8
83 lines (77 loc) · 2.63 KB
/
check_for_examples.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
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
name: Check Documentation
on:
pull_request:
paths:
- 'docs/data-sources/*.md'
- 'docs/resources/*.md'
jobs:
check-example-usage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for "## Example Usage"
id: check
run: |
FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} | grep '\.md$' | grep -v 'CHANGELOG\.md$')
MISSING=""
for FILE in $FILES; do
if ! grep -q '## Example Usage' "$FILE"; then
MISSING="$MISSING\n$FILE"
fi
done
if [ -n "$MISSING" ]; then
echo "::set-output name=missing::$MISSING"
echo -e "The following files are missing '## Example Usage':$MISSING"
exit 1
fi
- name: Create comment
if: failure()
uses: actions/github-script@v5
with:
script: |
const issue_number = context.payload.pull_request.number;
const message = `The following files are missing '## Example Usage':\n${{ steps.check.outputs.missing }}`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});
check-subcategory:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check for "subcategory:"
id: check
run: |
FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} | grep '\.md$'| grep -v 'CHANGELOG\.md$')
MISSING=""
for FILE in $FILES; do
if ! grep -q 'subcategory: .\+' "$FILE"; then
MISSING="$MISSING\n$FILE"
fi
done
if [ -n "$MISSING" ]; then
echo "::set-output name=missing::$MISSING"
echo -e "The following files are missing a string after 'subcategory:':$MISSING"
exit 1
fi
- name: Create comment
if: failure()
uses: actions/github-script@v5
with:
script: |
const issue_number = context.payload.pull_request.number;
const message = `The following files don't have a subcategory':\n${{ steps.check.outputs.missing }}`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});