-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (156 loc) · 5.73 KB
/
daily.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Daily get UP-FRONT & Hello!Project YouTube view count
env:
ACCESS_TOKEN: ${{secrets.ACCESS_TOKEN}}
ACCESS_TOKEN_SECRET: ${{secrets.ACCESS_TOKEN_SECRET}}
API_KEY: ${{secrets.API_KEY}}
API_SECRET: ${{secrets.API_SECRET}}
YTV3_API_KEY: ${{secrets.YTV3_API_KEY}}
DEBUG: NO
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FIREBASE_CREDENTIAL: ${{ secrets.FIREBASE_CREDENTIAL }}
TZ: 'Asia/Tokyo'
on:
schedule:
- cron: '0 23 * * *'
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
jobs:
crawl:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Firefox
run: bash < firefox-install.sh
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install -q -U pip
pip install -q pipenv
pipenv install -q
pip freeze
rm -rf images/*
rm -rf html/*
- name: get today data
id: main-async-py
run: |
pipenv run python main.async.py 2>&1 | tee -a ./out.txt
continue-on-error: true
- name: generate graph
id: graph_gen-py
run: |
pipenv run python graph_gen.py 2>&1 | tee -a ./out.txt
continue-on-error: true
- name: generate table & markdown data
id: table_gen-py
run: |
pipenv run python table_gen.py 2>&1 | tee -a ./out.txt
continue-on-error: true
- name: debug-ls
run: |
find . -maxdepth 2 -type f
pwd
- name: Cache markdown data
uses: actions/cache@v4
with:
path: |
markdown.pickle
save.sqlite
key: ${{ github.sha }}-cache
- name: debug-ls
run: |
find . -maxdepth 2 -type f
pwd
- name: tweet
id: tweet-py
run: |
pipenv run python tweet.py 2>&1 | tee -a ./out.txt
continue-on-error: true
- name: push updates
run: |
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
if (git diff --shortstat | grep '[0-9]'); then \
git status; \
git add save.sqlite graph/* html/* table/* tsvs/* -f; \
git commit -m "Daily updates"; \
git push origin HEAD:${GITHUB_REF} -f ; \
fi
- name: Print status
run: |
echo "${{steps.main-async-py.outcome}}"
echo "${{steps.graph_gen-py.outcome}}"
echo "${{steps.table_gen-py.outcome}}"
echo "${{steps.tweet-py.outcome}}"
- name: Error Handling
if: steps.main-async-py.outcome == 'failure' || steps.graph_gen-py.outcome == 'failure' || steps.table_gen-py.outcome == 'failure' || steps.tweet-py.outcome == 'failure'
run: |
pipenv run post-processing
exit 1
- name: Upload Log
if: steps.main-async-py.outcome == 'success' && steps.graph_gen-py.outcome == 'success' && steps.table_gen-py.outcome == 'success' && steps.tweet-py.outcome == 'success'
run: |
pipenv run upload-log
excel_export:
timeout-minutes: 10
runs-on: ubuntu-latest
needs:
- crawl
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install -q -U pip
pip install -q pandas lxml styleframe openpyxl
- name: Version
id: versioning
run: echo "tag_name=`date '+%Y.%m.%d'`" >> "$GITHUB_OUTPUT"
# - name: convert SQLite to Excel
# run: python excel_exporter.py
- run: rm save.sqlite
- name: debug-ls
run: |
find . -maxdepth 2 -type f
pwd
- name: Restore markdown data
uses: actions/cache@v4
with:
path: |
markdown.pickle
save.sqlite
key: ${{ github.sha }}-cache
- name: convert SQLite to Excel
run: python excel_exporter.py
- name: generate daily report & release note
run: |
python daily_report.py $GITHUB_SHA
grep -e "^[#🥇🥈🥉]" daily_report.md | sed -e '/^#/! s/\([~|#]\)/\\\1/g' > release_note.md
- name: Tagging
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add export.xlsx
git commit -m "convert SQLite to Excel"
git tag ${{ steps.versioning.outputs.tag_name }}
git push origin ${{ steps.versioning.outputs.tag_name }}
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
export.xlsx
daily_report.md
body_path: release_note.md
tag_name: ${{ steps.versioning.outputs.tag_name }}
name: ${{ steps.versioning.outputs.tag_name }}
generate_release_notes: false