-
-
Notifications
You must be signed in to change notification settings - Fork 15
48 lines (46 loc) · 1.52 KB
/
sort.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
name: Sort CSV Files
on:
push:
paths:
- 'source/**'
- 'tools/sort_lists.py'
jobs:
sort-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Print sort_lists version
run: |
python -c "import tools.sort_lists; print(f'Sort Lists Version: {tools.sort_lists.VERSION}')"
- name: Check for changes in source folder
id: changed_files
run: |
if [ $(git rev-list --count HEAD) -gt 1 ]; then
changed_files=$(git diff --name-only HEAD~1 HEAD | grep -E '^source/.*\.csv$')
else
changed_files=$(git ls-files | grep -E '^source/.*\.csv$')
fi
sanitized_changed_files=$(echo "$changed_files" | tr '\n' ' ')
echo "changed_files=$sanitized_changed_files" >> $GITHUB_ENV
- name: Sort CSV files
if: env.changed_files
run: |
python tools/sort_lists.py
- name: Commit changes
if: env.changed_files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "spirillen"
git add source/
git commit -m "Sort CSV files" -a
git push