-
Notifications
You must be signed in to change notification settings - Fork 2
145 lines (134 loc) · 6.63 KB
/
deploy-storacha.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
name: Deploy Storacha
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
jobs:
test:
uses: ./.github/workflows/test.yml
preview:
name: Preview
needs:
- test
runs-on: ubuntu-latest
permissions:
pull-requests: write
environment:
name: ${{ (github.ref_name == 'main') && 'staging' || format('preview-{0}', github.ref_name) }}
url: ${{ (github.ref_name == 'main') && 'https://staging.console.web3.storage/' || steps.cloudflare_url.outputs.stdout }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/pnpm
- name: create .env from .env.tpl setting env variables used by `pnpm run pages:build`
run: |
# set env vars from template
# omit these because they are added manually in the next step
function excludeDefaultServiceVariables() {
cat - | grep -v NEXT_PUBLIC_W3UP_SERVICE_ | grep -v NEXT_PUBLIC_STRIPE
}
# set .env from .env.tpl with exclusions
cat .env.tpl | excludeDefaultServiceVariables > .env
# add vars configuring console frontend to use staging w3up as backend
echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:staging.web3.storage" >> .env
echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://staging.up.storacha.network" >> .env
echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:staging.web3.storage" >> .env
echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1NzhdvF6A5ufQX5vKNZuRhie" >> .env
echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51LO87hF6A5ufQX5viNsPTbuErzfavdrEFoBuaJJPfoIhzQXdOUdefwL70YewaXA32ZrSRbK4U4fqebC7SVtyeNcz00qmgNgueC" >> .env
echo "NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL_LINK=https://billing.stripe.com/p/login/test_6oE29Gff99KO6mk8ww" >> .env
# as long as this uses https://github.com/cloudflare/next-on-pages/blob/dc529d7efa8f8568ea8f71b5cdcf78df89be6c12/packages/next-on-pages/bin/index.js,
# env vars won't get passed through to wrangler, so if wrangler will need them, write them to .env like the previous step
- run: pnpm pages:build
- name: Deploy preview build to Cloudflare Pages
uses: mathiasvr/[email protected]
id: cloudflare
with:
run: npx wrangler pages deploy --project-name "$CLOUDFLARE_PAGES_PROJECT_NAME" --branch "$GITHUB_REF_NAME" --commit-hash "$GITHUB_SHA" .vercel/output/static
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
CLOUDFLARE_PAGES_PROJECT_NAME: ${{ (github.ref_name == 'main') && 'console-web3-storage-staging' || 'console-web3-storage-preview' }}
- name: Find Cloudflare Pages preview URL
uses: mathiasvr/[email protected]
id: cloudflare_url
with:
run: egrep -o 'https?://[^ ]+' <(echo "${{ steps.cloudflare.outputs.stdout }}")
- name: Find Current Pull Request
uses: jwalton/[email protected]
id: finder
- name: Update Preview URLs PR Comment
uses: marocchino/[email protected]
with:
number: ${{ steps.finder.outputs.pr }}
message: |
### Website preview 🔗✨
- ⛅️ ${{ steps.cloudflare_url.outputs.stdout }}
[build log](/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: Add Preview URLs as Job Summary
run: |
echo "
### Website preview 🔗✨
- ⛅️ ${{ steps.cloudflare_url.outputs.stdout }}
[build log](/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
changelog:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Changelog
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
releases_created: ${{ steps.tag-release.outputs.releases_created }}
steps:
- uses: GoogleCloudPlatform/release-please-action@v3
id: tag-release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Other Changes","hidden":false}]'
release:
name: Release
if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.changelog.outputs.releases_created) || inputs.force_release
runs-on: ubuntu-latest
environment:
name: production
url: https://console.storacha.network
needs:
- test
- changelog
steps:
- uses: actions/checkout@v3
with:
ref: 'main'
- uses: ./.github/actions/pnpm
- name: create .env from .env.tpl setting env variables used by `pnpm run pages:build`
run: |
# set env vars from template
# omit these because they are added manually in the next step
function excludeDefaultServiceVariables() {
cat - | grep -v NEXT_PUBLIC_W3UP_SERVICE_ | grep -v NEXT_PUBLIC_STRIPE
}
# set .env from .env.tpl with exclusions
cat .env.tpl | excludeDefaultServiceVariables > .env
# add vars configuring console frontend to use staging w3up as backend
echo "NEXT_PUBLIC_W3UP_SERVICE_DID=did:web:web3.storage" >> .env
echo "NEXT_PUBLIC_W3UP_SERVICE_URL=https://up.storacha.network" >> .env
echo "NEXT_PUBLIC_W3UP_PROVIDER=did:web:web3.storage" >> .env
echo "NEXT_PUBLIC_STRIPE_PRICING_TABLE_ID=prctbl_1OCJ1qF6A5ufQX5vM5DWg4rA" >> .env
echo "NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_51LO87hF6A5ufQX5vQTO5BHyz8y9ybJp4kg1GsBjYuqwluuwtQTkbeZzkoQweFQDlv7JaGjuIdUWAyuwXp3tmCfsM005lJK9aS8" >> .env
echo "NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL_LINK=https://billing.stripe.com/p/login/cN22aA62U6bO1sA9AA" >> .env
- run: pnpm pages:build
# as long as this uses https://github.com/cloudflare/next-on-pages/blob/dc529d7efa8f8568ea8f71b5cdcf78df89be6c12/packages/next-on-pages/bin/index.js,
# env vars won't get passed through to wrangler, so if wrangler will need them, write them to .env like the previous step
env: {}
- name: Deploy preview build to Cloudflare Pages
uses: mathiasvr/[email protected]
id: cloudflare
with:
run: npx wrangler pages deploy --project-name console-storacha --branch "main" --commit-hash "$GITHUB_SHA" .vercel/output/static
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}