-
Notifications
You must be signed in to change notification settings - Fork 6
52 lines (49 loc) · 1.55 KB
/
Copy pathmain.yml
File metadata and controls
52 lines (49 loc) · 1.55 KB
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
name: A workflow to automate updating download stats using Google Analytics 4
on:
schedule:
- cron: "0 1 1 * *"
workflow_dispatch:
inputs:
runMessage:
description: "Update Google Analytics"
required: true
default: "Testing"
permissions:
contents: write
actions: write
jobs:
graph:
name: Google Analytics 4 Update
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Execute Python script
env:
GA4_ACCOUNT_CRED: ${{ secrets.GA4_ACCOUNT_CRED }}
run: |
cd static
python data/google_analytics.py
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Push changes to GitHub
run: |
git config --local user.email "lixun910@gmail.com"
git config --local user.name "Xun Li"
git pull
git add static/data/download_data.json static/data/globe_log.json static/data/down_by_country.csv
git commit -m "Updated google analytics stats ${{ steps.date.outputs.date }}"
git push origin master
- name: Trigger GitHub Pages deployment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh workflow run deploy-to-github-pages.yml --ref master