This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (68 loc) · 2.48 KB
/
updatestations.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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