-
Notifications
You must be signed in to change notification settings - Fork 186
186 lines (168 loc) · 6.47 KB
/
deploy_examples.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
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) }}
SHARED_INFRA_VPC_ID: ${{ vars.SHARED_INFRA_VPC_ID }}
SHARED_INFRA_CLUSTER_ARN: ${{ vars.SHARED_INFRA_CLUSTER_ARN }}
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 }}
code=$!
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
exit $code
- name: Deploy Linearlite Read Only
working-directory: ./examples/linearlite-read-only
run: |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
code=$!
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
exit $code
- 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 }}
code=$!
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
exit $code
- name: Deploy NextJs example
working-directory: ./examples/nextjs
run: |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
code=$!
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
exit $code
- name: Deploy TODO App example
working-directory: ./examples/todo-app
run: |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
code=$!
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
exit $code
- name: Deploy proxy-auth example
working-directory: ./examples/proxy-auth
run: |
pnpm sst deploy --stage ${{ env.DEPLOY_ENV }}
code=$!
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
exit $code
- 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,
});
}