From a77a1bf8a9e9d581a3d7611b5f4a9d318dec49e0 Mon Sep 17 00:00:00 2001 From: Tobias Wilken Date: Sat, 22 Nov 2025 07:19:38 +0100 Subject: [PATCH] feat: add CI/CD pipeline with automated deployment 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 --- .github/workflows/ci.yml | 31 +++++++++++++++++++++ .github/workflows/deploy.yml | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b8ee7d1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.17' + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Run checks + run: npm run check + + - name: Build + run: npm run build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..fa5efdf --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,54 @@ +name: Deploy to Dokku + +on: + push: + branches: [main] + +jobs: + deploy: + name: Deploy to Production + runs-on: ubuntu-latest + + steps: + - name: Deploy to Dokku + run: | + echo "Triggering deployment for commit ${{ github.sha }}" + + response=$(curl -s -w "%{http_code}" -o response.json \ + -X POST https://server.tooangel.com/deploy/worlddriven-webapp \ + -H "Authorization: Bearer ${{ secrets.DEPLOY_WEBHOOK_SECRET }}" \ + -H "Content-Type: application/json" \ + -d '{ + "repository": "${{ github.repository }}", + "commit": "${{ github.sha }}", + "branch": "${{ github.ref_name }}" + }') + + http_code="${response: -3}" + + echo "HTTP Status Code: $http_code" + echo "Response:" + cat response.json + + if [ "$http_code" -ne 200 ]; then + echo "Deployment failed with HTTP status: $http_code" + exit 1 + fi + + echo "Deployment triggered successfully!" + + - name: Verify Deployment + run: | + echo "Waiting 30 seconds for deployment to complete..." + sleep 30 + + echo "Checking if worlddriven webapp is responding..." + response=$(curl -s -w "%{http_code}" -o health.json https://webapp.worlddriven.org/ || echo "000") + http_code="${response: -3}" + + if [ "$http_code" = "200" ]; then + echo "✅ Deployment successful - worlddriven webapp is responding" + else + echo "⚠️ Warning: worlddriven webapp may still be starting (HTTP $http_code)" + echo "This doesn't necessarily mean deployment failed." + fi