Skip to content

Commit 91a299c

Browse files
committed
Deploy HTML renderer to R2
1 parent 6a4f54e commit 91a299c

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
required: false
1919
default: "https://staging-editor-static.raspberrypi.org"
2020
type: string
21+
html_renderer_url:
22+
required: false
23+
default: "https://staging-editor-static.raspberrypi.org/"
24+
type: string
2125
react_app_api_endpoint:
2226
required: false
2327
default: "https://staging-editor-api.raspberrypi.org"
@@ -62,7 +66,7 @@ on:
6266
required: false
6367
default: "https://staging-editor.raspberrypi.org,https://staging-editor-static.raspberrypi.org"
6468
type: string
65-
69+
6670
secrets:
6771
AWS_ACCESS_KEY_ID:
6872
required: false
@@ -86,6 +90,7 @@ jobs:
8690
deploy_dir: ${{ steps.setup-environment.outputs.deploy_dir }}
8791
public_url: ${{ steps.setup-environment.outputs.public_url }}
8892
assets_url: ${{ steps.setup-environment.outputs.assets_url }}
93+
html_renderer_url: ${{ steps.setup-environment.outputs.html_renderer_url }}
8994
react_app_base_url: ${{ steps.setup-environment.outputs.react_app_base_url }}
9095
steps:
9196
- id: setup-environment
@@ -94,9 +99,11 @@ jobs:
9499
deploy_dir=${{inputs.prefix}}/$safe_ref_name
95100
public_url=${{inputs.base_url}}/$deploy_dir
96101
assets_url=${{inputs.assets_url}}/$deploy_dir
102+
html_renderer_url=${{inputs.html_renderer_url}}/$deploy_dir/html-renderer
97103
echo "deploy_dir=$deploy_dir" >> $GITHUB_OUTPUT
98104
echo "public_url=$public_url" >> $GITHUB_OUTPUT
99105
echo "assets_url=$assets_url" >> $GITHUB_OUTPUT
106+
echo "html_renderer_url=$html_renderer_url" >> $GITHUB_OUTPUT
100107
if [ "${{inputs.react_app_base_url}}" = "unspecified" ] ; then
101108
echo "react_app_base_url=$deploy_dir" >> $GITHUB_OUTPUT
102109
else
@@ -139,6 +146,7 @@ jobs:
139146
env:
140147
PUBLIC_URL: ${{ needs.setup-environment.outputs.public_url }}
141148
ASSETS_URL: ${{ needs.setup-environment.outputs.assets_url }}
149+
HTML_RENDERER_URL: ${{ needs.setup-environment.outputs.html_renderer_url }}
142150
REACT_APP_API_ENDPOINT: ${{ inputs.react_app_api_endpoint }}
143151
REACT_APP_AUTHENTICATION_CLIENT_ID: ${{ inputs.react_app_authentication_client_id }}
144152
REACT_APP_AUTHENTICATION_URL: ${{ inputs.react_app_authentication_url }}
@@ -151,11 +159,18 @@ jobs:
151159
REACT_APP_SENTRY_ENV: ${{ inputs.react_app_sentry_env }}
152160
REACT_APP_ALLOWED_IFRAME_ORIGINS: ${{ inputs.react_app_allowed_iframe_origins }}
153161

162+
- name: Build HTML renderer bundle
163+
run: yarn build-html-renderer
164+
env:
165+
PUBLIC_URL: ${{ needs.setup-environment.outputs.html_renderer_url}}
166+
REACT_APP_ALLOWED_IFRAME_ORIGINS: ${{ inputs.react_app_allowed_iframe_origins }}
167+
154168
- name: Deploy site to S3 bucket
155169
if: env.AWS_SECRET_ACCESS_KEY != ''
156170
run: |
157171
aws s3 sync ./build/ s3://${{ secrets.AWS_S3_BUCKET }}/${{ needs.setup-environment.outputs.deploy_dir }} --endpoint ${{ secrets.AWS_ENDPOINT }}
158172
aws s3 sync ./build/chunks/ s3://${{ secrets.AWS_S3_BUCKET }}/chunks/ --endpoint ${{ secrets.AWS_ENDPOINT }} --exclude "*" --include "fetch-worker*"
173+
aws s3 sync ./build-html-renderer/ s3://${{ secrets.AWS_S3_BUCKET }}/${{ needs.setup-environment.outputs.deploy_dir }}/html-renderer/ --endpoint ${{ secrets.AWS_ENDPOINT }}
159174
env:
160175
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
161176
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -168,7 +183,7 @@ jobs:
168183
curl -sS --fail-with-body -X POST "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \
169184
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
170185
-H "Content-Type: application/json" \
171-
--data '{"files":["${{ needs.setup-environment.outputs.public_url }}/web-component.html", "${{ needs.setup-environment.outputs.public_url }}/web-component.js", "${{ needs.setup-environment.outputs.public_url }}/scratch.html", "${{ needs.setup-environment.outputs.public_url }}/scratch.js"]}'
186+
--data '{"files":["${{ needs.setup-environment.outputs.public_url }}/web-component.html", "${{ needs.setup-environment.outputs.public_url }}/web-component.js", "${{ needs.setup-environment.outputs.public_url }}/scratch.html", "${{ needs.setup-environment.outputs.public_url }}/scratch.js", "${{ needs.setup-environment.outputs.html_renderer_url}}/index.html", "${{ needs.setup-environment.outputs.html_renderer_url}}/html_renderer.js]}"'
172187
)" || {
173188
echo "Cloudflare purge request failed:"
174189
echo "$response"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"start": "NODE_ENV=development BABEL_ENV=development webpack serve -c ./webpack.config.js",
8888
"start-html-renderer": "NODE_ENV=development BABEL_ENV=development webpack serve -c ./webpack.html-renderer.config.js",
8989
"build": "NODE_ENV=production BABEL_ENV=production webpack build -c ./webpack.config.js",
90+
"build-html-renderer": "NODE_ENV=production BABEL_ENV=production webpack build -c ./webpack.html-renderer.config.js",
9091
"analyze": "ANALYZE_WEBPACK_BUNDLE=true yarn build",
9192
"lint": "eslint 'src/**/*.{js,jsx}' cypress/**/*.js",
9293
"lint:fix": "eslint --fix 'src/**/*.{js,jsx}' cypress/**/*.js",

0 commit comments

Comments
 (0)