Skip to content

Commit ea9e0a4

Browse files
authored
feat: add CI/CD pipeline with automated deployment (#2)
Implement continuous integration and deployment workflows: - CI workflow runs linting, type checks, and builds on every push and PR - Deployment workflow automatically deploys to Dokku when code is pushed to main - Deploys to worlddriven-webapp Dokku app via deployment webhook - Includes health check verification after deployment
1 parent 6e66e55 commit ea9e0a4

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20.17'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm install
26+
27+
- name: Run checks
28+
run: npm run check
29+
30+
- name: Build
31+
run: npm run build

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy to Dokku
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy to Production
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Deploy to Dokku
14+
run: |
15+
echo "Triggering deployment for commit ${{ github.sha }}"
16+
17+
response=$(curl -s -w "%{http_code}" -o response.json \
18+
-X POST https://server.tooangel.com/deploy/worlddriven-webapp \
19+
-H "Authorization: Bearer ${{ secrets.DEPLOY_WEBHOOK_SECRET }}" \
20+
-H "Content-Type: application/json" \
21+
-d '{
22+
"repository": "${{ github.repository }}",
23+
"commit": "${{ github.sha }}",
24+
"branch": "${{ github.ref_name }}"
25+
}')
26+
27+
http_code="${response: -3}"
28+
29+
echo "HTTP Status Code: $http_code"
30+
echo "Response:"
31+
cat response.json
32+
33+
if [ "$http_code" -ne 200 ]; then
34+
echo "Deployment failed with HTTP status: $http_code"
35+
exit 1
36+
fi
37+
38+
echo "Deployment triggered successfully!"
39+
40+
- name: Verify Deployment
41+
run: |
42+
echo "Waiting 30 seconds for deployment to complete..."
43+
sleep 30
44+
45+
echo "Checking if worlddriven webapp is responding..."
46+
response=$(curl -s -w "%{http_code}" -o health.json https://webapp.worlddriven.org/ || echo "000")
47+
http_code="${response: -3}"
48+
49+
if [ "$http_code" = "200" ]; then
50+
echo "✅ Deployment successful - worlddriven webapp is responding"
51+
else
52+
echo "⚠️ Warning: worlddriven webapp may still be starting (HTTP $http_code)"
53+
echo "This doesn't necessarily mean deployment failed."
54+
fi

0 commit comments

Comments
 (0)