Skip to content

Commit c6ecedc

Browse files
committed
feat: update deploy process to facilitate staging/prod environments
1 parent dd0d992 commit c6ecedc

File tree

11 files changed

+34
-124
lines changed

11 files changed

+34
-124
lines changed

.github/workflows/release.yml

+7-32
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ on:
44
branches:
55
- "main"
66
tags: ["*"]
7-
env:
8-
ROOT_DOMAIN: strn.pl
97
jobs:
108
cicd:
119
runs-on: ubuntu-latest
1210
steps:
1311
- uses: actions/checkout@v4
14-
with:
15-
# https://github.com/filecoin-saturn-team token to allow force pushing to protected branches
16-
token: ${{ secrets.FORCE_PUSH_TOKEN }}
1712

1813
- uses: actions/setup-node@v2
1914
with:
@@ -25,33 +20,13 @@ jobs:
2520
- name: Run Tests
2621
run: npm run test
2722

23+
# Just checking if build succeeds.
2824
- name: Build
2925
env:
30-
STATIC_ORIGIN: https://saturn.tech
31-
L1_ORIGIN: https://l1s.saturn.ms
32-
TRUSTED_L1_ORIGIN: https://saturn.ms
33-
UNTRUSTED_L1_ORIGIN: https://l1s.saturn.ms
34-
LOG_INGESTOR_URL: https://twb3qukm2i654i3tnvx36char40aymqq.lambda-url.us-west-2.on.aws
26+
STATIC_FILE_ORIGIN: https://saturn-test.network
27+
L1_ORIGIN: https://l1s.saturn-test.ms
28+
TRUSTED_L1_ORIGIN: https://saturn-test.ms
29+
LOG_INGESTOR_URL: https://p6wofrb2zgwrf26mcxjpprivie0lshfx.lambda-url.us-west-2.on.aws
30+
JWT_AUTH_URL: https://fz3dyeyxmebszwhuiky7vggmsu0rlkoy.lambda-url.us-west-2.on.aws/
31+
ORCHESTRATOR_URL: https://orchestrator.strn-test.pl/nodes?maxNodes=100
3532
run: npm run build
36-
37-
- uses: EndBug/add-and-commit@v9
38-
if: github.ref_type == 'tag'
39-
with:
40-
add: "dist"
41-
default_author: user_info
42-
message: "[skip ci] CI Build"
43-
push: origin HEAD:main --force
44-
45-
- name: Trigger ./dist/* file replication in filecoin-saturn/homepage repo
46-
if: github.ref_type == 'tag'
47-
run: |
48-
code="$(curl -L \
49-
-X POST \
50-
-H "Accept: application/vnd.github+json" \
51-
-H "Authorization: Bearer ${{secrets.ACCESS_TOKEN}}" \
52-
-H "X-GitHub-Api-Version: 2022-11-28" \
53-
https://api.github.com/repos/filecoin-saturn/homepage/actions/workflows/copy-retrieval-client-files.yml/dispatches \
54-
-d '{"ref": "main"}' \
55-
-sw "%{http_code}\n")"
56-
57-
test "$code" -eq 204 || exit 1

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
node_modules
44
test-files
55

6-
# dist folder is watched by homepage git hook.
7-
dist/index.html
6+
dist/

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ a requirement when retrieving content in a trustless manner from community hoste
2727
2828
The service worker file can be found here: https://saturn.tech/saturn-sw.js
2929
30+
## Deployment
31+
32+
- To deploy to staging, push to `main`. Then trigger a staging homepage fleek deploy.
33+
34+
- To deploy to production, push a tag. Then trigger a prod homepage fleek deploy.
35+
36+
```bash
37+
git tag -m deploy $(date +%s)
38+
git push --follow-tags
39+
```
3040
3141
## License
3242

bin/deploy.sh

-71
This file was deleted.

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="utf-8"/>
5-
<script async src="<%= WIDGET_ORIGIN %>/widget.js#integration=<%= CLIENT_KEY %>"></script>
5+
<script async src="<%= STATIC_FILE_ORIGIN %>/widget.js#integration=<%= CLIENT_KEY %>"></script>
66
<style>
77
:root {
88
--cell-width: 400px;

src/sw/controller.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ export class Controller {
2424

2525
constructor () {
2626
this.clientId = getRetrievalClientId()
27-
this.clientKey = getClientKey()
2827
this.saturn = new Saturn({
29-
clientKey: this.clientKey,
28+
cdnURL: process.env.L1_ORIGIN,
29+
logURL: process.env.LOG_INGESTOR_URL,
30+
orchURL: process.env.ORCHESTRATOR_URL,
31+
authURL: process.env.JWT_AUTH_URL,
32+
clientKey: getClientKey(),
3033
storage: indexedDbStorage()
3134
})
32-
3335
}
3436

3537
start () {

src/sw/interceptor.js

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export class Interceptor {
2828
}
2929

3030
async fetch() {
31-
const contentItr = await this.saturn.fetchContent(this.cidPath)
3231
const self = this
3332

3433
const readableStream = new ReadableStream({

src/sw/saturn-sw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
DEDICATED_WORKER_PATH
1111
} from '@src/constants'
1212

13-
const origin = process.env.STATIC_ORIGIN
13+
const origin = process.env.STATIC_FILE_ORIGIN
1414

1515
if (typeof ServiceWorkerGlobalScope !== 'undefined') {
1616
const url = origin + SW_CORE_PATH

src/widget/widget-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// Retrieves widget config based on the script tag url.
33

4-
export const WIDGET_BASE_URL = `${process.env.WIDGET_ORIGIN}/widget.js`
4+
export const WIDGET_BASE_URL = `${process.env.STATIC_FILE_ORIGIN}/widget.js`
55

66
const CLIENT_KEY_IDENTIFIER = 'integration'
77

src/widget/widget.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function initWidget () {
5757
const config = widgetConfigFromScriptTag()
5858
const clientKey = config.clientKey
5959
addHeadElement('link', {
60-
href: process.env.UNTRUSTED_L1_ORIGIN,
60+
href: process.env.L1_ORIGIN,
6161
crossOrigin: '',
6262
rel: 'preconnect',
6363
id: 'saturn-preconnect'

webpack.config.js

+7-11
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ const devServerPort = 8030
2121
export default (env, { mode }) => {
2222
// Switch to .env files once this gets unwieldy
2323
const e = process.env
24-
const STATIC_ORIGIN = e.STATIC_ORIGIN ?? 'http://localhost:8030'
24+
const STATIC_FILE_ORIGIN = e.STATIC_FILE_ORIGIN ?? `http://localhost:${devServerPort}`
2525
const L1_ORIGIN = e.L1_ORIGIN ?? 'https://l1s.saturn-test.ms'
26-
const TRUSTED_L1_ORIGIN = e.TRUSTED_L1_ORIGIN ?? 'https://l1s.saturn-test.ms'
27-
const UNTRUSTED_L1_ORIGIN = e.UNTRUSTED_L1_ORIGIN ?? 'https://saturn-test.ms'
26+
const TRUSTED_L1_ORIGIN = e.TRUSTED_L1_ORIGIN ?? 'https://saturn-test.ms'
2827
const LOG_INGESTOR_URL = e.LOG_INGESTOR_URL ?? 'https://p6wofrb2zgwrf26mcxjpprivie0lshfx.lambda-url.us-west-2.on.aws'
2928
const JWT_AUTH_URL = e.JWT_AUTH_URL ?? 'https://fz3dyeyxmebszwhuiky7vggmsu0rlkoy.lambda-url.us-west-2.on.aws'
30-
const ORCHESTRATOR_URL = e.ORCHESTRATOR_URL ?? 'https://orchestrator.strn-test.pl/nodes'
31-
const WIDGET_ORIGIN = e.WIDGET_ORIGIN ?? `http://localhost:${8030}`
29+
const ORCHESTRATOR_URL = e.ORCHESTRATOR_URL ?? 'https://orchestrator.strn-test.pl/nodes?maxNodes=100'
3230

3331
return {
34-
// Uncomment snapshot for webpack to detect edits in node_modules/
32+
// Uncomment snapshot for webpack to detect edits in node_modules/
3533
snapshot: {
3634
managedPaths: [],
3735
},
@@ -53,19 +51,17 @@ export default (env, { mode }) => {
5351
output: {
5452
path: abspath('dist'),
5553
clean: true,
56-
publicPath: STATIC_ORIGIN + '/',
54+
publicPath: STATIC_FILE_ORIGIN + '/',
5755
},
5856
plugins: [
5957
new webpack.EnvironmentPlugin({
6058
COMMITHASH: JSON.stringify(gitPlugin.commithash()),
61-
STATIC_ORIGIN,
59+
STATIC_FILE_ORIGIN,
6260
L1_ORIGIN,
6361
TRUSTED_L1_ORIGIN,
64-
UNTRUSTED_L1_ORIGIN,
6562
LOG_INGESTOR_URL,
6663
JWT_AUTH_URL,
6764
ORCHESTRATOR_URL,
68-
WIDGET_ORIGIN
6965
}),
7066
new ESLintPlugin({
7167
emitError: false,
@@ -80,7 +76,7 @@ export default (env, { mode }) => {
8076
templateParameters: {
8177
// Arc prod client key
8278
CLIENT_KEY: '1205a0fe-142c-40a2-a830-8bbaf6382c3f',
83-
WIDGET_ORIGIN,
79+
STATIC_FILE_ORIGIN,
8480
}
8581
})
8682
],

0 commit comments

Comments
 (0)