This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
generate stations report #156
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: generate stations report | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ ] | |
schedule: | |
- cron: "5 7 2 * *" # on the second day of the month | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
repository_dispatch: # run workflow on api request | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: clone this repo | |
run: git clone https://github.com/${{ github.repository }}.git twfg-stations | |
- name: update packages | |
run: sudo apt-get update && sudo apt-get upgrade | |
- name: Setup Python 3.x | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: install virtualenv | |
run: pip install virtualenv | |
- name: init virtualenv | |
run: virtualenv venv | |
- name: activate virtualenv | |
run: source venv/bin/activate | |
- name: upgrade pip | |
run: python -m pip install --upgrade pip | |
- name: list directory contents | |
run: ls -lisha | |
- name: install pip dependencies | |
run: pip install -r twfg-stations/requirements.txt | |
- name: download and compare stations | |
run: python twfg-stations/__init__.py | |
- name: copy stations-report.json to github repo directory | |
run: cp stations-report.json twfg-stations/ || true | |
- name: write lastmod.txt file | |
run: echo $(date +%Y-%m-%d_%H:%M) > twfg-stations/lastmod.txt || true | |
- name: list directory contents | |
run: ls -lisha | |
- name: return directory size | |
run: du -sh | |
- name: archive generated json files | |
uses: actions/[email protected] | |
with: | |
name: generated-json | |
path: | | |
*.json | |
- name: git push to origin | |
run: | | |
cd twfg-stations | |
git config --local user.name twfgcicdbot | |
git config --local user.email [email protected] | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
git fetch --all | |
git checkout main | |
git reset | |
git add lastmod.txt | |
git add stations-report.json | |
git status | |
git commit -m "update stations-report.json" || true | |
git push -f origin main || true | |