-
Notifications
You must be signed in to change notification settings - Fork 119
173 lines (167 loc) · 6.1 KB
/
website.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
name: Website
on:
push:
branches:
- main
paths:
- 'packages/website/**'
- '.github/workflows/website.yml'
pull_request:
paths:
- 'packages/website/**'
- '.github/workflows/website.yml'
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: bahmutov/npm-install@v1
- run: npm run lint:ts -w packages/website
test-e2e:
name: ${{ matrix.os }} (${{ matrix.browser }})
strategy:
fail-fast: false
matrix:
browser:
- firefox
- chromium
os:
- ubuntu-18.04
node-version:
- 16
test_results_path:
# corresponds to playwright invocation/configuration
- packages/website/test-results
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: bahmutov/npm-install@v1
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build -w packages/website
env:
NEXT_PUBLIC_API: http://localhost:8787
NEXT_PUBLIC_ENV: test-e2e
NEXT_PUBLIC_MAGIC: ${{ secrets.STAGING_MAGIC_PUBLIC_KEY }}
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
working-directory: packages/website
- run: touch .env
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run -w @web3-storage/website test:e2e -- --project=${{ matrix.browser }}
env:
NEXT_PUBLIC_API: http://localhost:8787
NEXT_PUBLIC_ENV: dev
NEXT_PUBLIC_MAGIC: ${{ secrets.STAGING_MAGIC_PUBLIC_KEY }}
- name: Check for website test results
id: check_website_test_results
uses: andstor/file-existence-action@v1
with:
files: ${{ matrix.test_results_path }}
- if: steps.check_website_test_results.outputs.files_exists == 'true'
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.browser }}-${{ matrix.os }}-test-results
path: ${{ matrix.test_results_path }}
build:
name: Build & Add to IPFS
runs-on: ubuntu-latest
outputs:
cid: ${{ steps.ipfs.outputs.cid }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16
- uses: bahmutov/npm-install@v1
- run: npm run build -w packages/client
- run: npm run build -w packages/website
env:
NEXT_PUBLIC_ENV: staging
NEXT_PUBLIC_API: https://api-staging.web3.storage
NEXT_PUBLIC_MAGIC: ${{ secrets.STAGING_MAGIC_PUBLIC_KEY }}
NEXT_PUBLIC_COUNTLY_URL: ${{ secrets.COUNTLY_URL }}
NEXT_PUBLIC_COUNTLY_KEY: ${{ secrets.COUNTLY_KEY }}
- run: npm run build -w packages/docs
# Add the site to web3.storage, output the cid as `steps.ipfs.outputs.cid`
- name: Add to web3.storage
uses: web3-storage/add-to-web3@v2
id: ipfs
with:
path_to_add: packages/website/out
web3_token: ${{ secrets.WEB3_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo ${{ steps.ipfs.outputs.url }}
# Publish to the staging domain if it's a change on main 🚀
deploy:
name: Deploy https://staging.web3.storage
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- run: npx dnslink-cloudflare --record staging --domain web3.storage --link /ipfs/${{ needs.build.outputs.cid }}
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Release
runs-on: ubuntu-latest
needs:
- test
- build
steps:
- uses: GoogleCloudPlatform/release-please-action@v3
id: tag-release
with:
path: packages/website
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
monorepo-tags: true
package-name: website
- uses: actions/checkout@v2
if: ${{ steps.tag-release.outputs.releases_created }}
- uses: actions/setup-node@v2
if: ${{ steps.tag-release.outputs.releases_created }}
with:
node-version: '16'
registry-url: https://registry.npmjs.org/
- uses: bahmutov/npm-install@v1
if: ${{ steps.tag-release.outputs.releases_created }}
# --- Website deploy steps ----------------------------------------------
- name: Deploy to Cloudflare pages
if: ${{ steps.tag-release.outputs.releases_created }}
# Reset the `website-prod` branch to trigger a production build & deploy on Cloudflare Pages.
run: |
git push origin --delete website-prod
git push origin main:website-prod
- run: npm run build -w packages/client
if: ${{ steps.tag-release.outputs.releases_created }}
- run: npm run build -w packages/website
if: ${{ steps.tag-release.outputs.releases_created }}
env:
NEXT_PUBLIC_ENV: production
NEXT_PUBLIC_API: https://api.web3.storage
NEXT_PUBLIC_MAGIC: ${{ secrets.PROD_MAGIC_PUBLIC_KEY }}
NEXT_PUBLIC_COUNTLY_URL: ${{ secrets.COUNTLY_URL }}
NEXT_PUBLIC_COUNTLY_KEY: ${{ secrets.COUNTLY_KEY }}
# Add the site to web3.storage, output the cid as `steps.ipfs.outputs.cid`
- name: Add to web3.storage
if: ${{ steps.tag-release.outputs.releases_created }}
uses: web3-storage/add-to-web3@v2
id: ipfs
with:
path_to_add: packages/website/out
web3_token: ${{ secrets.WEB3_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy https://web3.storage
if: ${{ steps.tag-release.outputs.releases_created }}
run: npx dnslink-cloudflare --record _dnslink --domain web3.storage --link /ipfs/${{ steps.ipfs.outputs.cid }}
env:
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}