This repository has been archived by the owner on Oct 13, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
176 lines (149 loc) · 5.63 KB
/
update-pages.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
---
name: Update
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
push:
branches: [master]
schedule:
- cron: '0 12 * * *' # every day at noon
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
update_database:
runs-on: windows-latest # use windows because orca needs a display
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout database
uses: actions/checkout@v4
with:
ref: database
path: database
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
- name: Get current date
id: date
shell: bash
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
# get yesterday's date for tmdb download
MONTH=$(date +'%m')
DAY=$(date +'%d')
YEAR=$(date +'%Y')
YESTERDAY=$(($DAY-1))
echo "tmdb_date=${MONTH}_${YESTERDAY}_${YEAR}" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
- name: Install npm dependencies
run: |
npm install
- name: Update
env:
TMDB_API_KEY_V3: ${{ secrets.TMDB_API_KEY_V3 }}
TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }}
TWITCH_CLIENT_SECRET: ${{ secrets.TWITCH_CLIENT_SECRET }}
if: # only if secrets are available
(env.TMDB_API_KEY_V3 != null)
run: |
# get daily movies list from tmdb
# wget https://files.tmdb.org/p/exports/movie_ids_${{ steps.date.outputs.tmdb_date }}.json.gz \
# -O movies.json.gz
# get daily collections list from tmdb
# wget https://files.tmdb.org/p/exports/collection_ids_${{ steps.date.outputs.tmdb_date }}.json.gz \
# -O collections.json.gz
python -u ./src/updater.py --daily_update
- name: Archive database
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
7z \
"-xr!*.git*" \
a "./database.zip" "./database"
- name: Upload Artifacts
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: database
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
path: |
${{ github.workspace }}/database.zip
- name: GitHub Commit & Push
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: actions-js/[email protected]
with:
author_email: ${{ secrets.GH_BOT_EMAIL }}
author_name: ${{ secrets.GH_BOT_NAME }}
branch: database # commit to database
directory: database # use the database directory
github_token: ${{ secrets.GH_BOT_TOKEN }}
message: automatic-update-${{ steps.date.outputs.date }}
update_pages:
needs: [update_database]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout database
uses: actions/checkout@v4
with:
ref: database
path: database
- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Prepare gh-pages
run: |
# empty contents
rm -f -r ./gh-pages/*
# copy template back to pages
cp -f -r ./gh-pages-template/. ./gh-pages/
# copy database back to pages
rm -rf ./database/.git # remove git directory
cp -f -r ./database/. ./gh-pages/
- name: Archive gh-pages
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
7z \
"-xr!*.git*" \
a "./gh-pages.zip" "./gh-pages"
- name: Upload Artifacts
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: gh-pages
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
path: |
${{ github.workspace }}/gh-pages.zip
- name: Deploy to gh-pages
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: actions-js/[email protected]
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
author_email: ${{ secrets.GH_BOT_EMAIL }}
author_name: ${{ secrets.GH_BOT_NAME }}
directory: gh-pages
branch: gh-pages
force: false
message: automatic-update-${{ steps.date.outputs.date }}