diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 200d080..f7e2109 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Build Jekyll Site +name: Build & Deploy Jekyll Site on: push: @@ -27,3 +27,31 @@ jobs: JEKYLL_ENV=production bundle exec jekyll build env: JEKYLL_ENV: production + + - name: Deploy to DigitalOcean App Platform + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + run: | + # Find app ID by name + APP_ID=$(curl -s -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -H "Content-Type: application/json" \ + "https://api.digitalocean.com/v2/apps?page=1&page_limit=20" | \ + jq -r '.apps[] | select(.spec.name == "simcoetradesjournal") | .id') + + if [ -z "$APP_ID" ] || [ "$APP_ID" = "null" ]; then + echo "ERROR: Could not find DO app 'simcoetradesjournal'" + exit 1 + fi + + echo "Found DO app ID: $APP_ID" + + # Trigger deployment + DEPLOY_RESPONSE=$(curl -s -X POST \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -H "Content-Type: application/json" \ + "https://api.digitalocean.com/v2/apps/$APP_ID/deploy") + + DEPLOY_ID=$(echo "$DEPLOY_RESPONSE" | jq -r '.deployments[0].id') + echo "Deployment triggered: $DEPLOY_ID" + echo "Response: $DEPLOY_RESPONSE" + env: + DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }}