name: Build & Deploy Jekyll Site on: push: branches: - main pull_request: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: '3.3' bundler-cache: true - name: Build site with Jekyll run: | 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 }}