-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add public deployment of LinearLite (#1929)
Took changes from #1915 on top of main --------- Co-authored-by: Kyle Mathews <[email protected]> Co-authored-by: rob <[email protected]>
- Loading branch information
1 parent
b507743
commit 032a71d
Showing
31 changed files
with
3,961 additions
and
3,219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: Deploy Examples | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
pull_request: | ||
paths: ['examples/*/**'] | ||
|
||
concurrency: | ||
group: ${{ github.event_name == 'push' && 'prod-deploy-group' || format('examples-pr-{0}', github.event.number) }} | ||
|
||
jobs: | ||
deploy-examples: | ||
name: Deploy Examples | ||
environment: ${{ github.event_name == 'push' && 'Production' || 'Pull request' }} | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DEPLOY_ENV: ${{ github.event_name == 'push' && 'production' || format('pr-{0}', github.event.number) }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_DEFAULT_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_DEFAULT_ACCOUNT_ID }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | ||
NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} | ||
ELECTRIC_API: ${{ secrets.ELECTRIC_API }} | ||
ELECTRIC_ADMIN_API: ${{ secrets.ELECTRIC_ADMIN_API }} | ||
# HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} TODO | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Cache SST state | ||
uses: actions/cache@v4 | ||
with: | ||
path: .sst | ||
key: sst-cache-main-${{ runner.os }} | ||
restore-keys: | | ||
sst-cache-main-${{ runner.os }} | ||
- name: Deploy Linearlite | ||
working-directory: examples/linearlite | ||
run: | | ||
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | ||
if [ -f ".sst/outputs.json" ]; then | ||
linearlite=$(jq -r '.website' .sst/outputs.json) | ||
echo "linearlite=$linearlite" >> $GITHUB_ENV | ||
else | ||
echo "sst outputs file not found. Exiting." | ||
exit 1 | ||
fi | ||
- name: Deploy NextJs example | ||
working-directory: examples/nextjs-example | ||
run: | | ||
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | ||
if [ -f ".sst/outputs.json" ]; then | ||
nextjs=$(jq -r '.website' .sst/outputs.json) | ||
echo "nextjs=$nextjs" >> $GITHUB_ENV | ||
else | ||
echo "sst outputs file not found. Exiting." | ||
exit 1 | ||
fi | ||
- name: Add comment to PR | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const linearlite = process.env.linearlite; | ||
const nextjs = process.env.nextjs; | ||
const prNumber = context.issue.number; | ||
const commentBody = `## Examples | ||
- linearlite: ${linearlite} | ||
- nextjs: ${nextjs} | ||
`; | ||
const { data: comments } = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
}); | ||
const existingComment = comments.find(comment => comment.user.login ==='github-actions[bot]' && comment.body.startsWith("## Examples")); | ||
if (existingComment) { | ||
// Update the existing comment | ||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: existingComment.id, | ||
body: commentBody, | ||
}); | ||
} else { | ||
// Create a new comment if none exists | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: prNumber, | ||
body: commentBody, | ||
}); | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Teardown Examples PR stack | ||
|
||
on: | ||
pull_request: | ||
paths: ['examples/*/**'] | ||
types: [closed] | ||
|
||
concurrency: | ||
group: examples-pr-${{ github.event.number }} | ||
|
||
jobs: | ||
teardown-pr-stack: | ||
name: Teardown Examples PR stack | ||
environment: Pull request | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
DEPLOY_ENV: ${{ github.event_name == 'push' && 'production' || format('pr-{0}', github.event.number) }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_DEFAULT_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_DEFAULT_ACCOUNT_ID }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | ||
NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} | ||
ELECTRIC_API: ${{ secrets.ELECTRIC_API }} | ||
ELECTRIC_ADMIN_API: ${{ secrets.ELECTRIC_ADMIN_API }} | ||
# HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} TODO | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Cache SST state | ||
uses: actions/cache@v4 | ||
with: | ||
path: .sst | ||
key: sst-cache-${{ github.event.number }}-${{ runner.os }} | ||
restore-keys: | | ||
sst-cache-${{ runner.os }} | ||
- name: Remove Linearlite | ||
working-directory: examples/linearlite | ||
run: | | ||
export PR_NUMBER=${{ github.event.number }} | ||
echo "Removing stage pr-$PR_NUMBER" | ||
pnpm sst remove --stage "pr-$PR_NUMBER" | ||
- name: Remove NextJs example | ||
working-directory: examples/nextjs-example | ||
run: | | ||
export PR_NUMBER=${{ github.event.number }} | ||
echo "Removing stage pr-$PR_NUMBER" | ||
pnpm sst remove --stage "pr-$PR_NUMBER" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
`eslint:recommended`, | ||
`plugin:@typescript-eslint/recommended`, | ||
`plugin:prettier/recommended`, | ||
], | ||
parserOptions: { | ||
ecmaVersion: 2022, | ||
requireConfigFile: false, | ||
sourceType: `module`, | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
parser: `@typescript-eslint/parser`, | ||
plugins: [`prettier`], | ||
rules: { | ||
quotes: [`error`, `backtick`], | ||
"no-unused-vars": `off`, | ||
"@typescript-eslint/no-unused-vars": [ | ||
`error`, | ||
{ | ||
argsIgnorePattern: `^_`, | ||
varsIgnorePattern: `^_`, | ||
caughtErrorsIgnorePattern: `^_`, | ||
}, | ||
], | ||
}, | ||
ignorePatterns: [ | ||
`**/node_modules/**`, | ||
`**/dist/**`, | ||
`tsup.config.ts`, | ||
`vitest.config.ts`, | ||
`.eslintrc.js`, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist | ||
.env.local | ||
db/data/ | ||
db/data/ | ||
.sst/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import "./src/global.d.ts" | ||
import "../types.generated" | ||
import { AppInput, App, Config } from "./src/config" | ||
import * as _neon from "@sst-provider/neon"; | ||
import * as _cloudflare from "@pulumi/cloudflare"; | ||
import * as _aws from "@pulumi/aws"; | ||
|
||
|
||
declare global { | ||
// @ts-expect-error | ||
export import neon = _neon | ||
// @ts-expect-error | ||
export import cloudflare = _cloudflare | ||
// @ts-expect-error | ||
export import aws = _aws | ||
interface Providers { | ||
providers?: { | ||
"neon"?: (_neon.ProviderArgs & { version?: string }) | boolean | string; | ||
"cloudflare"?: (_cloudflare.ProviderArgs & { version?: string }) | boolean | string; | ||
"aws"?: (_aws.ProviderArgs & { version?: string }) | boolean | string; | ||
} | ||
} | ||
export const $config: ( | ||
input: Omit<Config, "app"> & { | ||
app(input: AppInput): Omit<App, "providers"> & Providers; | ||
}, | ||
) => Config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export const baseUrl = import.meta.env.ELECTRIC_URL ?? `http://localhost:3000` | ||
export const baseUrl = import.meta.env.VITE_ELECTRIC_URL | ||
? new URL(import.meta.env.VITE_ELECTRIC_URL).origin | ||
: `http://localhost:3000` | ||
export const token = import.meta.env.VITE_ELECTRIC_TOKEN ?? `` | ||
export const databaseId = import.meta.env.VITE_DATABASE_ID ?? `` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.