|
1 |
| -name: A workflow to automate downloads graph and globe updates |
| 1 | +name: A workflow to automate updating download stats using Google Analytics 4 |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | schedule:
|
5 |
| - - cron: '0 1 1 * *' |
| 5 | + - cron: "0 1 1 * *" |
6 | 6 | workflow_dispatch:
|
7 | 7 | inputs:
|
8 | 8 | runMessage:
|
9 |
| - description: 'Run Message' |
| 9 | + description: "Update Google Analytics" |
10 | 10 | required: true
|
11 |
| - default: 'Testing' |
| 11 | + default: "Testing" |
12 | 12 |
|
13 | 13 | jobs:
|
14 | 14 | graph:
|
15 |
| - name: Downloads Graph Update |
| 15 | + name: Google Analytics 4 Update |
16 | 16 | runs-on: ubuntu-latest
|
17 | 17 | steps:
|
18 | 18 | - uses: actions/checkout@v2
|
19 | 19 | - name: Set up Python
|
20 | 20 | uses: actions/setup-python@v2
|
21 | 21 | with:
|
22 |
| - python-version: '3.x' |
| 22 | + python-version: "3.8" |
23 | 23 | - name: Install dependencies
|
24 | 24 | run: |
|
25 | 25 | python -m pip install --upgrade pip
|
26 | 26 | pip install -r requirements.txt
|
27 | 27 | - name: Execute Python script
|
28 | 28 | env:
|
29 |
| - ACCOUNT_INFO: ${{ secrets.CLIENT_SECRETS }} |
| 29 | + GA4_ACCOUNT_CRED: ${{ secrets.GA4_ACCOUNT_CRED }} |
30 | 30 | run: |
|
31 |
| - python data/download_update.py |
| 31 | + python data/google_analytics.py |
| 32 | + - name: Get current date |
| 33 | + id: date |
| 34 | + run: echo "::set-output name=date::$(date +'%Y-%m-%d')" |
32 | 35 | - name: Push changes to GitHub
|
33 | 36 | run: |
|
34 |
| - git config --local user.email "bzlbzlbzl2000iscool@gmail.com" |
35 |
| - git config --local user.name "Bzlbzlbzl" |
| 37 | + git config --local user.email "lixun910@gmail.com" |
| 38 | + git config --local user.name "Xun Li" |
36 | 39 | git pull
|
37 |
| - git add data/download_data.json |
38 |
| - git commit -m "Updated downloads graph for last month" |
39 |
| - git push origin master |
40 |
| - globe: |
41 |
| - needs: graph |
42 |
| - name: Downloads Globe Update |
43 |
| - runs-on: ubuntu-latest |
44 |
| - steps: |
45 |
| - - uses: actions/checkout@v2 |
46 |
| - - name: Set up Python |
47 |
| - uses: actions/setup-python@v2 |
48 |
| - with: |
49 |
| - python-version: '3.x' |
50 |
| - - name: Install dependencies |
51 |
| - run: | |
52 |
| - python -m pip install --upgrade pip |
53 |
| - pip install -r requirements.txt |
54 |
| - - name: Execute Python script |
55 |
| - env: |
56 |
| - ACCOUNT_INFO: ${{ secrets.CLIENT_SECRETS }} |
57 |
| - run: | |
58 |
| - python data/globe_update.py |
59 |
| - - name: Push changes to GitHub |
60 |
| - run: | |
61 |
| - git config --local user.email "[email protected]" |
62 |
| - git config --local user.name "Bzlbzlbzl" |
63 |
| - git pull |
64 |
| - git add data/globe_log.json data/down_by_country.csv |
65 |
| - git commit -m "Updated downloads globe for last month" |
| 40 | + git add data/download_data.json data/globe_log.json data/down_by_country.csv |
| 41 | + git commit -m "Updated google analytics stats ${{ steps.date.outputs.date }}" |
66 | 42 | git push origin master
|
0 commit comments