-
Notifications
You must be signed in to change notification settings - Fork 7
47 lines (42 loc) · 1.45 KB
/
workflow.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
name: data-sorter
run-name: Push by ${{ github.actor }} is sorting station mappings.json
on:
push:
branches:
- "*"
- "*/**"
- "!main" # Exclude the main branch
permissions: write-all
jobs:
consolidate-and-sort-data:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v2 # checkout the repository content
- name: setup python
uses: actions/setup-python@v4
with:
python-version: "3.11" # install the python version needed
- name: Check, sort and consolidate data
id: consolidate
working-directory: .
run: python .github/workflows/main.py
- name: Check script outcome
run: |
if [ ${{ steps.consolidate.outcome }} != 'success' ]; then
echo "Sorting and consolidation of data failed, data invalid"
exit 1
fi
- if: ${{ steps.consolidate.outcome == 'success' }}
name: commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git diff-index --quiet HEAD || (git commit -a -m "Consolidated and formatted data" --allow-empty)
- if: ${{ steps.consolidate.outcome == 'success' }}
name: push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}