-
Notifications
You must be signed in to change notification settings - Fork 13
66 lines (56 loc) · 2.14 KB
/
main.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
# This workflow runs the JSON checker on each vendordep JSON file.
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
env:
YEAR: 2025
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "run-json-checker"
run-json-checker:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so we can use git diff
- name: Install dependencies
run: sudo pip3 install pyelftools pefile
- name: Run check
run: |
# Determine the base commit
if [ "${{ github.event_name }}" = "pull_request" ]; then
git fetch --no-tags --prune --progress --no-recurse-submodules origin ${{ github.base_ref }}
BASE_COMMIT=$(git merge-base HEAD origin/${{ github.base_ref }})
else
BASE_COMMIT=${{ github.event.before }}
fi
echo "Base commit: $BASE_COMMIT"
# Get list of added or modified JSON files in subdirectories
git diff --diff-filter=AM --name-only $BASE_COMMIT HEAD | grep '.*/.*\.json$' > changed_json_files.txt || true
# Run check.py on each existing JSON file
if [ -s changed_json_files.txt ]; then
# Output the list of files
echo "Changed JSON files in subdirectories:"
cat changed_json_files.txt
while read -r file; do
if [ -f "$file" ]; then
if [ -s "$file" ]; then
echo "Processing $file"
./check.py "$file"
else
echo "Warning: $file is empty."
fi
else
echo "Warning: $file does not exist."
fi
done < changed_json_files.txt
else
echo "No JSON files changed in subdirectories, checking year: $YEAR"
./check.py $YEAR/*.json
fi