-
Notifications
You must be signed in to change notification settings - Fork 702
127 lines (98 loc) · 4.17 KB
/
cli-r2.yaml
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
name: CLI R2
on:
push:
branches:
- "*.staging"
# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
group: vercel-cli-r2-${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
statuses: write # This is required for the GitHub Script createCommitStatus to work
packages: write
jobs:
build:
env:
COMPATIBILITY_DATE: 2024-04-10
environment:
name: "staging"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.sha }} # HEAD commit instead of merge commit
- uses: pnpm/[email protected]
- uses: actions/setup-node@v3
with:
node-version: "18.x"
cache: pnpm
- name: pnpm instal
run: pnpm install --ignore-scripts
- name: pnpm build
run: pnpm --filter 'webstudio-cloudlfare-template^...' run build
- name: pnpm deploy
run: pnpm --filter 'webstudio-cloudlfare-template' deploy "${{ github.workspace }}/../cloudlfare-template"
- name: cleanup cloudflare template
run: |
find . -name 'typescript@*' -type d -prune -exec rm -rf '{}' + && \
find . -name '@storybook*' -type d -prune -exec rm -rf '{}' + && \
find . -name 'eslint@*' -type d -prune -exec rm -rf '{}' + && \
find . -name '@types+node@*' -type d -prune -exec rm -rf '{}' + && \
find . -name '@cloudflare+workers-types@*' -type d -prune -exec rm -rf '{}' +
working-directory: ${{ github.workspace }}/../cloudlfare-template
- name: Make archive
run: |
tar --use-compress-program="zstd -19" -cf cloudlfare-template.tar.zst cloudlfare-template
working-directory: ${{ github.workspace }}/..
- name: Copy artifact
run: |
curl https://rclone.org/install.sh | sudo bash
# For staging
rclone copy -P -M \
--no-check-dest \
./cloudlfare-template.tar.zst "r2:/${ARTEFACT_BUCKET_NAME}/public/cloudlfare-template/${{ github.ref_name }}.tar.zst"
# For production
rclone copy -P -M \
--no-check-dest \
./cloudlfare-template.tar.zst "r2:/${ARTEFACT_BUCKET_NAME}/public/cloudlfare-template/${{ github.sha }}.tar.zst"
working-directory: ${{ github.workspace }}/..
env:
RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.RCLONE_CONFIG_R2_ACCESS_KEY_ID }}
RCLONE_CONFIG_R2_ACL: ${{ secrets.RCLONE_CONFIG_R2_ACL }}
RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.RCLONE_CONFIG_R2_ENDPOINT }}
RCLONE_CONFIG_R2_PROVIDER: ${{ secrets.RCLONE_CONFIG_R2_PROVIDER }}
RCLONE_CONFIG_R2_TYPE: ${{ secrets.RCLONE_CONFIG_R2_TYPE }}
RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.RCLONE_CONFIG_R2_SECRET_ACCESS_KEY }}
ARTEFACT_BUCKET_NAME: ${{ secrets.ARTEFACT_BUCKET_NAME }}
checks:
environment:
name: "staging"
runs-on: ubuntu-latest
needs: build
steps:
- uses: pnpm/[email protected]
- uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Copy atrifact via http
run: curl -o cloudlfare-template.tar.zst ${{ secrets.ARTEFACT_BUCKET_URL }}/public/cloudlfare-template/${{ github.ref_name }}.tar.zst
- name: Extract archive
run: tar --use-compress-program="zstd -d" -xf cloudlfare-template.tar.zst -C .
- name: Webstudio Build
run: pnpm webstudio build --template internal --template saas-helpers --template cloudflare --assets false
working-directory: ${{ github.workspace }}/cloudlfare-template
- name: Remix Build
run: pnpm build
working-directory: ${{ github.workspace }}/cloudlfare-template
- name: WRANGLER Build
run: |
NODE_ENV=production pnpm wrangler deploy \
--name build \
--compatibility-date '${COMPATIBILITY_DATE}' \
--minify true \
--logpush true \
--dry-run \
--outdir dist \
'./functions/[[path]].ts'
working-directory: ${{ github.workspace }}/cloudlfare-template