name: Deploy on: push: branches: [main] jobs: build: runs-on: ubuntu-latest steps: - name: Checkout run: | git config --global --add safe.directory '*' git clone --depth 1 "https://hoelee:${{ secrets.PAT }}@git.hoelee.com/hoelee/hoelee-blog.git" . git checkout $GITHUB_SHA 2>/dev/null || true - name: Install dependencies run: npm ci - name: Build run: npm run build - name: Deploy to nginx-hoelee-blog run: | rm -rf /mnt/user/docker/nginx-hoelee-blog/html/* cp -r dist/* /mnt/user/docker/nginx-hoelee-blog/html/ echo "Deployed. Contents:" ls -la /mnt/user/docker/nginx-hoelee-blog/html/ # Purge the Cloudflare edge after deploy. Required as soon as an HTML cache # rule exists at the edge (Caching -> Cache Rules): without a purge, a new or # edited post can keep serving the old HTML until the Edge TTL expires. # Skipped silently while the secrets are unset so the deploy never breaks. - name: Purge Cloudflare cache run: | if [ -z "${CF_TOKEN}" ] || [ -z "${CF_ZONE_ID}" ]; then echo "CF_TOKEN / CF_ZONE_ID not set — skipping purge (add both as repo secrets)" exit 0 fi echo "Purging zone ${CF_ZONE_ID} ..." curl -sS -X POST "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/purge_cache" \ -H "Authorization: Bearer ${CF_TOKEN}" \ -H "Content-Type: application/json" \ --data '{"purge_everything":true}' | head -c 400 echo env: CF_TOKEN: ${{ secrets.CF_TOKEN }} CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}