-
Notifications
You must be signed in to change notification settings - Fork 67
103 lines (91 loc) · 3.15 KB
/
about_daangn_com-build.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
name: Build about.daangn.com
on:
workflow_dispatch:
inputs:
deployment_id:
description: Deployment ID
type: string
required: true
bind_url:
description: Bind URL from the websites-deployment worker
type: string
required: true
callback_url:
description: Callback URL from the websites-deployment worker
type: string
required: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Bind this to the deployment
run: |
curl -fsSL -X POST \
-H "Authorization: AdminKey ${{ secrets.WEBSITES_ADMIN_KEY }}" \
-H "Content-Type: application/json" \
-d '{ "run_id": "${{ github.run_id }}" }' \
"${{ inputs.bind_url }}"
- uses: actions/checkout@v4
- name: Setup Rclone
uses: cometkim/rclone-actions/setup-rclone@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Rclone
run: |
mkdir -p ~/.config/rclone
{
echo "[r2]"
echo "type = s3"
echo "provider = Cloudflare"
echo "access_key_id = ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}"
echo "secret_access_key = ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}"
echo "endpoint = https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com"
echo "acl = private"
} > ~/.config/rclone/rclone.conf
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
- name: Install Dependencies
run: yarn install --immutable
- name: Restore cache
id: content-cache
uses: actions/cache/restore@v4
with:
path: |
about.daangn.com/public
about.daangn.com/.cache
key: cache-about_daangn_com
- name: Build about.daangn.com
id: build
run: yarn workspace about.daangn.com build
- name: Build artifact
run: |
cd about.daangn.com && \
tar --use-compress-program="zstd -T0 --adapt --exclude-compressed" \
-cvf "public.tar.zst" \
"public/"
- name: Upload artifact
run: |
cd about.daangn.com && \
rclone copyto \
--stats 5 \
--log-level INFO \
--disable-http2 \
--buffer-size 128M \
--s3-chunk-size 128M \
--s3-upload-concurrency 4 \
--contimeout 10s --timeout 300s \
--retries 5 --low-level-retries 10 \
"public.tar.zst" \
"r2:websites-artifacts/about.daangn.com/${{ inputs.deployment_id }}.tar.zst"
- name: Execute callback
if: ${{ always() }}
run: |
curl -fsSL -X POST \
-H "Authorization: AdminKey ${{ secrets.WEBSITES_ADMIN_KEY }}" \
-H "Content-Type: application/json" \
-d '{ "run_id": "${{ github.run_id }}", "status": "${{ job.status }}", "artifact_name": "about.daangn.com/${{ inputs.deployment_id }}.tar.zst" }' \
"${{ inputs.callback_url }}"