Skip to content

Commit 2e2e7cd

Browse files
committed
preview deployment
1 parent 2b64aca commit 2e2e7cd

2 files changed

Lines changed: 59 additions & 56 deletions

File tree

.github/workflows/deploy.yaml

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
name: deployment from main branch
2-
3-
permissions:
4-
contents: write
1+
name: production deployment
52

63
on:
7-
push:
8-
branches:
9-
- main
10-
paths-ignore:
11-
- '*.md'
124
workflow_dispatch:
135

146
jobs:
@@ -18,28 +10,6 @@ jobs:
1810
steps:
1911
- name: Checkout code
2012
uses: actions/checkout@v5
21-
with:
22-
fetch-depth: 0
23-
persist-credentials: true
24-
25-
- name: Fetch tags
26-
run: git fetch --tags --force
27-
28-
- name: Compute diff since last deploy (database/scripts only)
29-
id: diff
30-
run: |
31-
if git rev-parse deploy-prod >/dev/null 2>&1; then
32-
if git diff --quiet deploy-prod...HEAD -- database/ scripts/; then
33-
echo "db_changed=false" >> $GITHUB_OUTPUT
34-
echo "No changes in database"
35-
else
36-
echo "db_changed=true" >> $GITHUB_OUTPUT
37-
echo "Changes detected in database"
38-
fi
39-
else
40-
echo "db_changed=true" >> $GITHUB_OUTPUT
41-
echo "No deploy-prod tag found"
42-
fi
4313

4414
- name: Install pnpm
4515
uses: pnpm/action-setup@v4
@@ -58,15 +28,7 @@ jobs:
5828
- name: Generate SvelteKit config
5929
run: pnpm svelte-kit sync
6030

61-
- name: Set deployment status
62-
if: steps.diff.outputs.db_changed == 'true'
63-
env:
64-
DB_URL: ${{ secrets.DB_URL }}
65-
DB_AUTH_TOKEN: ${{ secrets.DB_AUTH_TOKEN }}
66-
run: pnpm db:start-deploy
67-
6831
- name: Update database
69-
if: steps.diff.outputs.db_changed == 'true'
7032
env:
7133
DB_URL: ${{ secrets.DB_URL }}
7234
DB_AUTH_TOKEN: ${{ secrets.DB_AUTH_TOKEN }}
@@ -81,27 +43,11 @@ jobs:
8143
INTERNAL_API_KEY: ${{ secrets.INTERNAL_API_KEY }}
8244
run: pnpm build
8345

84-
- name: Deploy to Netlify
46+
- name: Deploy to Netlify - Production
8547
run: |
8648
pnpm exec netlify deploy --no-build \
8749
--dir build \
8850
--site ${{ secrets.NETLIFY_SITE_ID }} \
8951
--auth ${{ secrets.NETLIFY_ACCESS_TOKEN }} \
9052
--message "${{ github.event.head_commit.message }}" \
9153
--prod
92-
93-
- name: Update deploy tag
94-
if: github.ref == 'refs/heads/main'
95-
run: |
96-
git config user.name "github-actions[bot]"
97-
git config user.email "github-actions[bot]@users.noreply.github.com"
98-
99-
git tag -f deploy-prod $GITHUB_SHA
100-
git push --no-verify origin refs/tags/deploy-prod --force
101-
102-
- name: Reset deployment status
103-
if: always()
104-
env:
105-
DB_URL: ${{ secrets.DB_URL }}
106-
DB_AUTH_TOKEN: ${{ secrets.DB_AUTH_TOKEN }}
107-
run: pnpm db:finish-deploy
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: preview deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '*.md'
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v5
18+
19+
- name: Install pnpm
20+
uses: pnpm/action-setup@v4
21+
with:
22+
version: 10
23+
24+
- name: Use Node.js
25+
uses: actions/setup-node@v5
26+
with:
27+
node-version: 24.14.0
28+
cache: 'pnpm'
29+
30+
- name: Install Dependencies
31+
run: pnpm i
32+
33+
- name: Generate SvelteKit config
34+
run: pnpm svelte-kit sync
35+
36+
- name: Update database
37+
env:
38+
DB_URL: ${{ secrets.DB_PREVIEW_URL }}
39+
DB_AUTH_TOKEN: ${{ secrets.DB_PREVIEW_AUTH_TOKEN }}
40+
run: pnpm db:update
41+
42+
- name: Build app
43+
env:
44+
DB_URL: ${{ secrets.DB_PREVIEW_URL }}
45+
DB_AUTH_TOKEN: ${{ secrets.DB_PREVIEW_AUTH_TOKEN }}
46+
DB_HTTP_URL: ${{ secrets.DB_PREVIEW_HTTP_URL }}
47+
DB_AUTH_TOKEN_HTTP: ${{ secrets.DB_PREVIEW_AUTH_TOKEN_HTTP }}
48+
INTERNAL_API_KEY: ${{ secrets.INTERNAL_API_KEY }}
49+
run: pnpm build
50+
51+
- name: Deploy to Netlify - Preview
52+
run: |
53+
pnpm exec netlify deploy --no-build \
54+
--dir build \
55+
--site ${{ secrets.NETLIFY_SITE_ID }} \
56+
--auth ${{ secrets.NETLIFY_ACCESS_TOKEN }} \
57+
--message "${{ github.event.head_commit.message }}"

0 commit comments

Comments
 (0)