Skip to content

Commit a2fc1e1

Browse files
authored
Configure S3 to sync to a specific endpoint (#177)
Syncs build to new R2 bucket, using the S3 compatibility layer Adds AWS_ENDPOINT secret to ensure we send stuff to the correct API Moves all branches to the branches deploy directory, and all releases to the releases deploy directory, i.e. tag v0.x.0 will get deployed to prod_r2_bucket/releases/v0.x.0 branch foo will get deployed to staging_r2_bucket/branches/foo Branches are not deployed to the prod bucket, and releases are not deployed to staging. The intention is that staging tracks main (i.e. branches/main) and prod tracks the latest release from the KV store.
1 parent d5cd693 commit a2fc1e1

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

.github/workflows/build-and-deploy.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ on:
4141
required: true
4242
AWS_SECRET_ACCESS_KEY:
4343
required: true
44+
AWS_ENDPOINT:
45+
required: true
4446

4547
jobs:
4648
build-deploy:
@@ -58,13 +60,6 @@ jobs:
5860
node-version: 16
5961
cache: 'yarn'
6062

61-
- name: Configure AWS credentials
62-
uses: aws-actions/configure-aws-credentials@v1
63-
with:
64-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
65-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
66-
aws-region: ${{ secrets.AWS_REGION }}
67-
6863
- name: Install code
6964
run: yarn install --frozen-lock-file
7065

@@ -81,4 +76,8 @@ jobs:
8176
REACT_APP_LOGIN_ENABLED: ${{ inputs.react_app_login_enabled }}
8277

8378
- name: Deploy site to S3 bucket
84-
run: aws s3 sync ./build/ s3://${{ secrets.AWS_S3_BUCKET }}/${{ inputs.deploy_dir }} --delete
79+
run: aws s3 sync ./build/ s3://${{ secrets.AWS_S3_BUCKET }}/${{ inputs.deploy_dir }} --delete --endpoint ${{ secrets.AWS_ENDPOINT }}
80+
env:
81+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
82+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
83+
AWS_REGION: ${{ secrets.AWS_REGION }}

.github/workflows/main.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,36 +90,36 @@ jobs:
9090
cypress/videos
9191
9292
93-
build-and-deploy-release:
93+
build-and-deploy-tag:
9494
if: github.ref_type == 'tag'
9595
needs:
9696
- test
9797
uses: ./.github/workflows/build-and-deploy.yml
9898
with:
99-
deploy_dir: ${{ github.ref_name }}
99+
deploy_dir: releases/${{ github.ref_name }}
100100
environment: production
101-
public_url: https://editor.raspberrypi.org/${{ github.ref_name }}
101+
public_url: https://editor.raspberrypi.org/releases/${{ github.ref_name }}
102102
react_app_api_endpoint: https://editor-api.raspberrypi.org
103103
react_app_authentication_url: https://auth-v1.raspberrypi.org
104104
secrets: inherit
105105

106-
build-and-deploy-staging:
107-
if: github.ref == 'refs/heads/main'
106+
build-and-deploy-main:
107+
if: github.ref_type == 'branch' && github.ref_name == 'main'
108108
needs:
109109
- test
110110
uses: ./.github/workflows/build-and-deploy.yml
111111
with:
112-
deploy_dir: ${{ github.ref_name }}
112+
deploy_dir: branches/${{ github.ref_name }}
113113
environment: staging
114-
public_url: https://staging-editor.raspberrypi.org/${{ github.ref_name }}
114+
public_url: https://staging-editor.raspberrypi.org/branches/${{ github.ref_name }}
115115
secrets: inherit
116116

117-
build-and-deploy-preview:
118-
if: github.ref_type == 'branch' && github.ref != 'refs/heads/main'
117+
build-and-deploy-branch:
118+
if: github.ref_type == 'branch' && github.ref_name != 'main'
119119
uses: ./.github/workflows/build-and-deploy.yml
120120
with:
121-
deploy_dir: previews/${{ github.ref_name }}
121+
deploy_dir: branches/${{ github.ref_name }}
122122
environment: previews/${{ github.ref_name }}
123-
public_url: http://python-editor-dist-test.s3-website.eu-west-2.amazonaws.com/previews/${{ github.ref_name }}
123+
public_url: https://staging-editor.raspberrypi.org/branches/${{ github.ref_name }}
124124
secrets: inherit
125125

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
### Changed
99
- Update styling on the `sense_hat` visual output (#174)
1010
- Update build workflow with a reusable job to update preview, staging, and prod (#176)
11+
- Change deployment to use specific AWS endpoint, and deploy releases to `/releases/...` and branches to `/branches/..` (#177)
1112

1213
## [0.3.0]
1314

0 commit comments

Comments
 (0)