-
Notifications
You must be signed in to change notification settings - Fork 1k
54 lines (43 loc) · 1.44 KB
/
todos-check.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
name: Check TODOs and FIXMEs in Changed Files
on:
pull_request:
branches:
- master
- 'dev/*'
- 'rel/*'
- "rc/*"
- 'force_ci/**'
paths-ignore:
- 'docs/**'
- 'site/**'
# allow manually run the action:
workflow_dispatch:
jobs:
todo-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check for TODOs and FIXMEs in changed files
run: |
# Fetch the target branch
git fetch origin $GITHUB_BASE_REF
git switch -c check_branch
# Get the diff of the changes
echo Get the diff of the changes
DIFF=$(git diff origin/$GITHUB_BASE_REF check_branch -- . ':(exclude).github/workflows/todos-check.yml')
if [ -z "$DIFF" ]; then
echo "No changes detected."
exit 0
fi
# Check the diff for TODOs
# Check the diff for TODOs
echo Check the diff for TODOs
TODOsCOUNT=$(echo "$DIFF" | grep -E '^\+.*(TODO|FIXME)' | wc -l)
if [ "$TODOsCOUNT" -eq 0 ]; then
echo "No TODOs or FIXMEs found in changed content.";
exit 0
fi
echo "TODO or FIXME found in the changes. Please resolve it before merging."
echo "$DIFF" | grep -E '^\+.*(TODO|FIXME)' | tee -a output.log
exit 1