Push by LeoKle is sorting station mappings.json #277
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |