forked from MALSync/MALSync
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (144 loc) · 5.23 KB
/
Copy pathautoUrls.yml
File metadata and controls
165 lines (144 loc) · 5.23 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
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
name: "autoUrls"
on:
schedule:
- cron: '0 5 * * *'
workflow_dispatch:
push:
branches:
- master
paths:
- '**/meta.json'
- '**/playerUrls.js'
permissions:
contents: write
pull-requests: write
actions: write
jobs:
# ------------------------------------------------------------------
# JOB 1: PREPARE
# ------------------------------------------------------------------
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: master
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: '22.x'
cache: 'npm' # <--- Simple, standard caching
- name: Build
run: npm install
- id: set-matrix
name: Set Matrix
env:
CI_MODE: travis
SIMKL_API_ID: ${{ secrets.SIMKL_API_ID }}
SIMKL_API_SECRET: ${{ secrets.SIMKL_API_SECRET }}
MANGABAKA_API_ID: ${{ secrets.MANGABAKA_API_ID }}
MANGABAKA_API_SECRET: ${{ secrets.MANGABAKA_API_SECRET }}
run: |
TASKS=$(node webpackConfig/autoUrls.mjs --list)
echo "matrix=$TASKS" >> $GITHUB_OUTPUT
# ------------------------------------------------------------------
# JOB 2: UPDATE SITES
# ------------------------------------------------------------------
update-urls:
needs: prepare-matrix
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
matrix:
task: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: master
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: '22.x'
cache: 'npm' # <--- Restores cache automatically
- name: Build
run: npm install
- name: Run ${{ matrix.task }}
env:
CI_MODE: travis
SIMKL_API_ID: ${{ secrets.SIMKL_API_ID }}
SIMKL_API_SECRET: ${{ secrets.SIMKL_API_SECRET }}
MANGABAKA_API_ID: ${{ secrets.MANGABAKA_API_ID }}
MANGABAKA_API_SECRET: ${{ secrets.MANGABAKA_API_SECRET }}
run: node webpackConfig/autoUrls.mjs ${{ matrix.task }}
- name: Stage Site Changes
run: |
mkdir -p scraped_data
git diff --name-only src/ | xargs -I {} cp --parents {} scraped_data/ 2>/dev/null || true
touch scraped_data/.keep
- name: Create Pull Request
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7
with:
commit-message: 'Auto Urls: ${{ matrix.task }}'
branch: 'auto-urls-${{ matrix.task }}'
delete-branch: true
title: 'Auto Urls: ${{ matrix.task }}'
body: 'Automatically added Urls for ${{ matrix.task }}'
labels: 'auto-urls'
add-paths: |
src/pages-chibi
src/pages/**/*.ts
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: site-data-${{ matrix.task }}
path: scraped_data/
retention-days: 1
if-no-files-found: ignore
# ------------------------------------------------------------------
# JOB 3: AGGREGATE PERMISSIONS
# ------------------------------------------------------------------
build-permissions:
needs: update-urls
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: master
persist-credentials: false
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: '22.x'
cache: 'npm' # <--- Restores cache automatically
- name: Build
run: npm install
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: site-data-*
path: .
merge-multiple: true
- name: Delete Artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api --paginate repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts \
--jq '.artifacts[] | select(.name | startswith("site-data-")) | .id' \
| xargs -r -I {} gh api -X DELETE repos/${{ github.repository }}/actions/artifacts/{}
- name: Build Permissions & Types
run: |
npm run build:missingPermissions
npm run build:chibiTypes
npm run lint:fix
- name: Create Aggregate PR
uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7
with:
commit-message: 'chore: update permissions and types'
branch: 'auto-urls-aggregate'
delete-branch: true
title: 'Auto Urls: Update Permissions'
body: 'Aggregated permissions build from all auto-url jobs.'
labels: 'auto-urls'
add-paths: |
src/**/*.json
src/**/*.js