-
-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (87 loc) · 3.37 KB
/
update.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
name: Release
on:
workflow_dispatch:
inputs:
build_container:
type: boolean
description: "Should this build also build a new Docker image"
schedule:
- cron: '41 */12 * * *' # At minute 41 past every 12th hour
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
- name: Setup
run: |
npm --no-audit --progress=false ci &
(curl --location --remote-name https://storage.gmodwiki.com/build_cache.zip && unzip -q build_cache.zip && rm -v build_cache.zip) &
(curl --location --remote-name https://storage.gmodwiki.com/public_cache.zip && unzip -q public_cache.zip && rm -v public_cache.zip) &
wait
- name: Remove expired files
run: |
npm run clear_recent_changes
- name: Scrape and Build
env:
BUILD_ENV: production
run: |
npm run build
- name: Build final pack
env:
BUILD_ENV: production
run: |
# Temporarily move it out of the public dir to keep it out of the Cloudflare bundle
# (it's too big, we upload it to R2 but include it in the docker image)
mv --verbose ./public/search_index.json .
npm run astrobuild
# Remote cache
- name: Prepare remote cache files
run: |
zip --recurse-paths -9 --quiet public_cache.zip ./public &
zip --recurse-paths -9 --quiet build_cache.zip ./build/cache &
wait
- name: Upload storage assets
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
run: |
(npx wrangler r2 object put gmodwiki/public_cache.zip --file ./public_cache.zip && rm -v public_cache.zip) &
(npx wrangler r2 object put gmodwiki/build_cache.zip --file ./build_cache.zip && rm -v build_cache.zip) &
(npx wrangler r2 object put gmodwiki/search_index.json --file ./search_index.json && mv ./search_index.json ./public/) &
wait
# CF Publish
- name: Publish Site
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
run: |
npx wrangler pages deploy --project-name=gmodwiki ./dist
- name: Clear CF Cache
env:
CLOUDFLARE_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CLOUDFLARE_CACHE_API_KEY: ${{ secrets.CF_CACHE_API_TOKEN }}
run: |
npm run clear_cloudflare_cache
rm --verbose deleted_files.json
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Docker
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.GH_TOKEN }}
- name: Build & Push Docker Image
if: ${{ (github.event_name == 'schedule' && (format('{{date:u}}')) == '1') || (github.event_name == 'workflow_dispatch' && github.event.inputs.build_container == 'true') }}
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/cfc-servers/gmodwiki:latest