Skip to content

Commit 409b05f

Browse files
committed
Implement scaffold website and deployment pipeline
1 parent 26e09cd commit 409b05f

File tree

9 files changed

+6686
-1
lines changed

9 files changed

+6686
-1
lines changed

.github/workflows/deploy-website.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish Website
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build_and_deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 12
16+
- run: npm ci
17+
working-directory: website
18+
- run: npm run export
19+
working-directory: website
20+
- uses: chrislennon/[email protected]
21+
- name: Deploy to S3
22+
run: aws s3 sync --delete out/ s3://debugmypipeline.com/ --acl=public-read --cache-control max-age=7200 --metadata-directive REPLACE
23+
working-directory: website
24+
env:
25+
AWS_ACCESS_KEY_ID: ${{ secrets.WEBSITE_AWS_ACCESS_KEY_ID }}
26+
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBSITE_AWS_SECRET_ACCESS_KEY }}
27+
- name: Invalidate CloudFront
28+
run: aws cloudfront create-invalidation --distribution-id=E34DDIH79LWROV --paths '/*'
29+
env:
30+
AWS_ACCESS_KEY_ID: ${{ secrets.WEBSITE_AWS_ACCESS_KEY_ID }}
31+
AWS_SECRET_ACCESS_KEY: ${{ secrets.WEBSITE_AWS_SECRET_ACCESS_KEY }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Temporary Items
3131
node_modules/
3232
dist/
3333
artifacts/
34+
out/
35+
.next/
3436

3537
# VS Code
3638
.vscode

server/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { TlsRelayServer } from './relay/relay.server';
88
async function bootstrap() {
99
const app = await NestFactory.create(AppModule);
1010

11-
app.enableCors({ origin: ['http://localhost', 'https://debugmypipeline.com'], allowedHeaders: '*' });
11+
app.enableCors({ origin: ['http://localhost:3003', 'https://debugmypipeline.com'], allowedHeaders: '*' });
1212

1313
const tlsRelay = app.get<TlsRelayServer>('TlsRelayServer');
1414

website/next-env.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

website/package-lock.json

+6,501
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "@timetoogo/debug-my-pipeline--website",
3+
"scripts": {
4+
"dev": "next dev -p 3003",
5+
"export": "next build && next export"
6+
},
7+
"dependencies": {
8+
"next": "9.3.6",
9+
"react": "16.13.1",
10+
"react-dom": "16.13.1"
11+
},
12+
"devDependencies": {
13+
"@types/node": "^13.13.5",
14+
"@types/react": "^16.9.34",
15+
"typescript": "^3.8.3"
16+
}
17+
}

website/pages/index.tsx

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import React, { useState } from 'react';
2+
import Head from 'next/head';
3+
4+
interface SessionKeys {
5+
hostKey: string;
6+
clientKey: string;
7+
}
8+
9+
export default function Home() {
10+
const [creatingSession, setCreatingSession] = useState<boolean>(false);
11+
const [sessionKeys, setSessionKeys] = useState<SessionKeys>();
12+
13+
const createSession = async () => {
14+
setCreatingSession(true);
15+
setSessionKeys(undefined);
16+
17+
try {
18+
const response = await fetch('http://127.0.0.1:3000/sessions', { method: 'POST' });
19+
20+
setSessionKeys(await response.json());
21+
} finally {
22+
setCreatingSession(false);
23+
}
24+
};
25+
26+
return (
27+
<div className="container">
28+
<Head>
29+
<title>Debug my pipeline</title>
30+
<link rel="icon" href="/favicon.ico" />
31+
</Head>
32+
33+
<main>
34+
<h1 className="title">Welcome to Debug My Pipeline</h1>
35+
36+
<ol>
37+
<li>
38+
<button onClick={createSession} disabled={creatingSession}>
39+
Create a session
40+
</button>
41+
</li>
42+
{creatingSession && <li>Loading...</li>}
43+
{sessionKeys && (
44+
<>
45+
<li>
46+
Run this command on your <strong>pipeline</strong>:
47+
<pre>sh &lt;(curl -s https://lets1.debugmypipeline.com/{sessionKeys.hostKey}.sh)</pre>
48+
</li>
49+
50+
<li>
51+
Run this command on your <strong>local machine</strong>:
52+
<pre>sh &lt;(curl -s https://lets1.debugmypipeline.com/{sessionKeys.clientKey}.sh)</pre>
53+
</li>
54+
</>
55+
)}
56+
</ol>
57+
</main>
58+
59+
<style jsx>{`
60+
.container {
61+
min-height: 100vh;
62+
padding: 0 0.5rem;
63+
display: flex;
64+
flex-direction: column;
65+
justify-content: center;
66+
align-items: center;
67+
}
68+
69+
main {
70+
padding: 5rem 0;
71+
flex: 1;
72+
display: flex;
73+
flex-direction: column;
74+
justify-content: center;
75+
align-items: center;
76+
}
77+
78+
ol * {
79+
font-size: 16px;
80+
}
81+
82+
ol li {
83+
margin-bottom: 20px;
84+
}
85+
`}</style>
86+
87+
<style jsx global>{`
88+
html,
89+
body {
90+
padding: 0;
91+
margin: 0;
92+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans,
93+
Droid Sans, Helvetica Neue, sans-serif;
94+
}
95+
96+
* {
97+
box-sizing: border-box;
98+
}
99+
`}</style>
100+
</div>
101+
);
102+
}

website/public/robots.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disallow: /

website/tsconfig.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
9+
"allowJs": true,
10+
"skipLibCheck": true,
11+
"strict": false,
12+
"forceConsistentCasingInFileNames": true,
13+
"noEmit": true,
14+
"esModuleInterop": true,
15+
"module": "esnext",
16+
"moduleResolution": "node",
17+
"resolveJsonModule": true,
18+
"isolatedModules": true,
19+
"jsx": "preserve"
20+
},
21+
"exclude": [
22+
"node_modules"
23+
],
24+
"include": [
25+
"next-env.d.ts",
26+
"**/*.ts",
27+
"**/*.tsx"
28+
]
29+
}

0 commit comments

Comments
 (0)