Skip to content

Commit 6f97ff6

Browse files
authored
Merge pull request #32 from Staffbase/NFS-add_S3_deployment
replacing netlify deployment with S3 deployment
2 parents e47ae59 + f8fae60 commit 6f97ff6

30 files changed

+1519
-347
lines changed

.github/workflows/autodev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
branches-ignore:
66
- dev
77
pull_request:
8-
types: [labeled, unlabeled, opened, closed]
8+
types: [labeled, unlabeled, closed]
99

1010
jobs:
1111
dev:

.github/workflows/cd.yaml

Lines changed: 100 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,124 @@
1-
name: Deploy samples to Netlify
2-
env:
3-
NODE_VERISON: 14
1+
name: Deploy to AWS S3
2+
43
on:
54
push:
6-
paths-ignore:
7-
- '**.md'
5+
branches: ['main', 'dev']
6+
release:
7+
types: [published]
8+
9+
env:
10+
NODE_VERSION: 16
811

912
jobs:
1013
build-and-deploy:
11-
if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main'
12-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-22.04
1315

1416
steps:
1517
- name: Checkout repository
16-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1719

1820
- name: Use Node JS
19-
uses: actions/setup-node@v2
21+
uses: actions/setup-node@v3
2022
with:
2123
node-version: ${{ env.NODE_VERSION }}
24+
cache: 'yarn'
25+
cache-dependency-path: samples/weather-forecast/yarn.lock
26+
registry-url: 'https://npm.pkg.github.com/'
27+
scope: '@staffbase'
28+
29+
- run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.STAFFBOT_NPM_READ }}" >> samples/weather-forecast/.npmrc
2230

23-
- name: Install Yarn Dependencies
31+
- name: Yarn install
2432
run: yarn install --cwd samples/weather-forecast --frozen-lockfile
2533

2634
- name: Build widget
2735
run: yarn --cwd samples/weather-forecast build
2836

2937
- name: Prepare Deployment
3038
run: |
31-
mkdir -p samples/deploy/icons
32-
cp samples/netlify.toml samples/deploy/
33-
cp samples/weather-forecast/dist/* samples/deploy/
34-
cp samples/weather-forecast/resources/weather-forecast.svg samples/deploy/icons/
35-
36-
- name: Publish to Production
37-
if: github.ref == 'main'
38-
uses: netlify/actions/cli@master
39+
mkdir samples/weather-forecast/icons
40+
cp samples/weather-forecast/resources/weather-forecast.svg samples/weather-forecast/dist/icons
41+
42+
- uses: actions/checkout@v3
43+
with:
44+
persist-credentials: false
45+
repository: Staffbase/S3-deployment-action
46+
ref: 1.0.1
47+
token: ${{ secrets.GITOPS_TOKEN }}
48+
path: .github/gitops
49+
50+
- name: Publish to S3 DE Prod
51+
if: github.event.release.tag_name != null
52+
uses: ./.github/gitops
53+
with:
54+
source: samples/weather-forecast/dist
55+
destination: widgets/weather
56+
57+
# Varnish settings
58+
static_files: |
59+
manifest.json
60+
frontend_host: frontend-cache-main-de1.staffbase.com
61+
frontend_cache_password: ${{ secrets.FRONTEND_CACHE_PROD_DE1_PASSWORD }}
62+
63+
# AWS specific settings
64+
aws_bucket: staffbasestatic-prod-de1
65+
aws_region: eu-central-1
66+
aws_access_key: ${{ secrets.PROD_DE1_AWS_ACCESS_KEY_ID }}
67+
aws_secret_key: ${{ secrets.PROD_DE1_AWS_ACCESS_KEY_SECRET }}
68+
69+
- name: Deploy to S3 US Prod
70+
if: github.event.release.tag_name != null
71+
uses: ./.github/gitops
72+
with:
73+
source: samples/weather-forecast/dist
74+
destination: widgets/weather
75+
76+
# Varnish settings
77+
static_files: |
78+
manifest.json
79+
frontend_host: frontend-cache-us1.staffbase.com
80+
frontend_cache_password: ${{ secrets.FRONTEND_CACHE_PROD_US1_PASSWORD }}
81+
82+
# AWS specific settings
83+
aws_bucket: staffbasestatic-prod-us1
84+
aws_region: us-east-1
85+
aws_access_key: ${{ secrets.PROD_US1_AWS_ACCESS_KEY_ID }}
86+
aws_secret_key: ${{ secrets.PROD_US1_AWS_ACCESS_KEY_SECRET }}
87+
88+
- name: Publish to S3 DE stage
89+
if: github.ref == 'refs/heads/main'
90+
uses: ./.github/gitops
3991
with:
40-
args: deploy --prod --dir=samples/deploy
41-
env:
42-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
43-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
92+
source: samples/weather-forecast/dist
93+
destination: widgets/weather
94+
95+
# Varnish settings
96+
static_files: |
97+
manifest.json
98+
frontend_host: frontend-cache-de1.staffbase.rocks
99+
frontend_cache_password: ${{ secrets.FRONTEND_CACHE_STAGE_DE1_PASSWORD }}
100+
101+
# AWS specific settings
102+
aws_bucket: staffbasestatic-stage-de1
103+
aws_region: eu-central-1
104+
aws_access_key: ${{ secrets.STAGE_DE1_AWS_ACCESS_KEY_ID }}
105+
aws_secret_key: ${{ secrets.STAGE_DE1_AWS_ACCESS_KEY_SECRET }}
44106

45-
- name: Publish to DevelopmentPreview
107+
- name: Publish to S3 DE dev
46108
if: github.ref == 'refs/heads/dev'
47-
uses: netlify/actions/cli@master
109+
uses: ./.github/gitops
48110
with:
49-
args: deploy --prod --dir=samples/deploy/
50-
env:
51-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_DEV }}
52-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN_DEV }}
111+
source: samples/weather-forecast/dist
112+
destination: widgets/weather
113+
114+
# Varnish settings
115+
static_files: |
116+
manifest.json
117+
frontend_host: frontend-cache-de1.staffbase.dev
118+
frontend_cache_password: ${{ secrets.FRONTEND_CACHE_DEV_DE1_PASSWORD }}
119+
120+
# AWS specific settings
121+
aws_bucket: staffbasestatic-dev-de1
122+
aws_region: eu-central-1
123+
aws_access_key: ${{ secrets.DEV_DE1_AWS_ACCESS_KEY_ID }}
124+
aws_secret_key: ${{ secrets.DEV_DE1_AWS_ACCESS_KEY_SECRET }}

.github/workflows/ci.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI Tests
22
env:
3-
NODE_VERISON: 14
3+
NODE_VERSION: 14
44
on:
55
push:
66
paths-ignore:
@@ -12,16 +12,22 @@ jobs:
1212

1313
steps:
1414
- name: Checkout repository
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v3
16+
with:
17+
persist-credentials: false
1618

17-
- name: Use Node JS
18-
uses: actions/setup-node@v2
19+
- name: Use Node.js Version
20+
uses: actions/setup-node@v3
1921
with:
2022
node-version: ${{ env.NODE_VERSION }}
23+
registry-url: 'https://npm.pkg.github.com/'
24+
scope: '@staffbase'
2125

2226
- name: Install Yarn Dependencies
2327
working-directory: samples/weather-forecast
2428
run: yarn install --frozen-lockfile
29+
env:
30+
NODE_AUTH_TOKEN: ${{ secrets.STAFFBOT_NPM_READ }}
2531

2632
- name: Run Build
2733
working-directory: samples/weather-forecast

samples/weather-forecast/.babelrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{
66
"useBuiltIns": "usage",
77
"corejs": 3,
8-
"targets": "> 0.25%, not dead, not ie < 11"
98
}
109
],
1110
"@babel/preset-react",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[production]
2+
extends @staffbase/browserslist-config
3+
4+
[development]
5+
extends @staffbase/browserslist-config
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from "react";
2+
3+
const MyComponent = props => <svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" width="1em" height="1em" {...props}><rect x={10} y={10} height={100} width={100} style={{
4+
stroke: "#ff0000",
5+
fill: "#0000ff"
6+
}} /></svg>;
7+
8+
export default MyComponent;

samples/weather-forecast/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
setupFilesAfterEnv: ["./test/jest-setup.js"],
33
resetMocks: true,
44
moduleNameMapper: {
5+
'icons/(.*)\.svg$': '<rootDir>/__mocks__/lazySvgMock.js',
56
'\\.svg$': '<rootDir>/__mocks__/fileMock.js',
67
},
78
testEnvironment: 'jsdom',

samples/weather-forecast/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"@material-ui/icons": "^4.11.2",
4242
"@rjsf/core": "^3.0.0",
4343
"@rjsf/material-ui": "^3.0.0",
44+
"@staffbase/browserslist-config": "1.0.0",
45+
"@svgr/webpack": "6.5.1",
4446
"@testing-library/dom": "8.2.0",
4547
"@testing-library/jest-dom": "5.14.1",
4648
"@testing-library/react": "12.0.0",
@@ -56,8 +58,8 @@
5658
"@ungap/custom-elements": "1.0.0",
5759
"babel-eslint": "10.1.0",
5860
"babel-loader": "^8.2.2",
59-
"core-js": "3.17.1",
6061
"copy-webpack-plugin": "^9.0.1",
62+
"core-js": "3.17.1",
6163
"eslint": "7.32.0",
6264
"eslint-config-prettier": "8.3.0",
6365
"eslint-plugin-prettier": "4.0.0",
@@ -76,10 +78,6 @@
7678
"webpack-dev-server": "^4.1.0",
7779
"webpack-merge": "^5.8.0"
7880
},
79-
"browserslist": [
80-
">0.2%",
81-
"not ie < 11"
82-
],
8381
"jest": {
8482
"setupFilesAfterEnv": [
8583
"jest-matchmedia-mock"

samples/weather-forecast/src/api/useCity.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ setLogger({
3838
});
3939

4040
describe("useCity", () => {
41-
const endpoint = "//api.openweathermap.org/geo/1.0/direct";
41+
const endpoint = "https://api.openweathermap.org/geo/1.0/direct";
4242

4343
afterEach(() => {
4444
queryClient.clear();

samples/weather-forecast/src/api/useCity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Options = {
2525
};
2626

2727
const getCoordinates = async (options: Options) => {
28-
const endpoint = "//api.openweathermap.org/geo/1.0/direct";
28+
const endpoint = "https://api.openweathermap.org/geo/1.0/direct";
2929

3030
const { key: appid, location: q } = options;
3131

0 commit comments

Comments
 (0)