feat: adds compaction (#2231) #528
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
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 }} | |
ELECTRIC_TEAM_ID: ${{ secrets.ELECTRIC_TEAM_ID }} | |
ELECTRIC_ADMIN_API_TOKEN_ID: ${{ secrets.ELECTRIC_ADMIN_API_TOKEN_ID }} | |
ELECTRIC_ADMIN_API_TOKEN_SECRET: ${{ secrets.ELECTRIC_ADMIN_API_TOKEN_SECRET }} | |
# HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} TODO | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".tool-versions" | |
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 Yjs example | |
working-directory: ./examples/yjs | |
run: | | |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | |
if [ -f ".sst/outputs.json" ]; then | |
yjs=$(jq -r '.website' .sst/outputs.json) | |
echo "yjs=$yjs" >> $GITHUB_ENV | |
else | |
echo "sst outputs file not found. Exiting." | |
exit 123 | |
fi | |
- name: Deploy Linearlite Read Only | |
working-directory: ./examples/linearlite-read-only | |
run: | | |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | |
if [ -f ".sst/outputs.json" ]; then | |
linearlite_read_only=$(jq -r '.website' .sst/outputs.json) | |
echo "linearlite_read_only=$linearlite_read_only" >> $GITHUB_ENV | |
else | |
echo "sst outputs file not found. Exiting." | |
exit 123 | |
fi | |
- name: Deploy Write Patterns example | |
working-directory: ./examples/write-patterns | |
run: | | |
pnpm --filter @electric-sql/client --filter @electric-sql/experimental --filter @electric-sql/react run build | |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | |
if [ -f ".sst/outputs.json" ]; then | |
writes=$(jq -r '.website' .sst/outputs.json) | |
echo "writes=$writes" >> $GITHUB_ENV | |
else | |
echo "sst outputs file not found. Exiting." | |
exit 123 | |
fi | |
- name: Deploy NextJs example | |
working-directory: ./examples/nextjs | |
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 123 | |
fi | |
- name: Deploy TODO App example | |
working-directory: ./examples/todo-app | |
run: | | |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | |
if [ -f ".sst/outputs.json" ]; then | |
todoapp=$(jq -r '.website' .sst/outputs.json) | |
echo "todoapp=$todoapp" >> $GITHUB_ENV | |
else | |
echo "sst outputs file not found. Exiting." | |
exit 123 | |
fi | |
- name: Deploy proxy-auth example | |
working-directory: ./examples/proxy-auth | |
run: | | |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }} | |
if [ -f ".sst/outputs.json" ]; then | |
auth=$(jq -r '.website' .sst/outputs.json) | |
echo "auth=$auth" >> $GITHUB_ENV | |
else | |
echo "sst outputs file not found. Exiting." | |
exit 123 | |
fi | |
- name: Add comment to PR | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const linearlite_read_only = process.env.linearlite_read_only; | |
const nextjs = process.env.nextjs; | |
const todoapp = process.env.todoapp; | |
const yjs = process.env.yjs; | |
const writes = process.env.writes; | |
const auth = process.env.auth; | |
const prNumber = context.issue.number; | |
const commentBody = `## Examples | |
- linearlite-read-only: ${linearlite_read_only} | |
- nextjs: ${nextjs} | |
- todoapp: ${todoapp} | |
- yjs: ${yjs} | |
- writes: ${writes} | |
- auth: ${auth} | |
`; | |
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, | |
}); | |
} |