Aimpress_site/.github/workflows/deploy.yml
Vadym Samoilenko b0de69b1d9 Fix TinaCloud schema sync: force re-index before build
The root cause of the schema mismatch was skipIfSchemaCurrent=true in
TinaCMS's syncProject() call, which caused TinaCloud to skip re-indexing
when it thought the schema SHA hadn't changed. This left TinaCloud with
a stale GraphQL schema missing the pages collection (PagesSeo type).

Fix: add an explicit curl step before the build that calls TinaCloud's
reset endpoint WITHOUT skipIfSchemaCurrent, forcing a full re-index.
Keep --skip-cloud-checks in the build command to avoid the circular
dependency (build failing because TinaCloud is still indexing).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-18 23:01:15 +00:00

61 lines
2 KiB
YAML

name: Deploy to Server
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Force TinaCloud schema re-index
run: |
echo "Triggering TinaCloud schema refresh..."
curl -s -X POST \
"https://content.tinajs.io/db/${TINA_PUBLIC_CLIENT_ID}/reset/main?refreshSchema=true" \
-H "X-API-KEY: ${TINA_TOKEN}" \
-H "Content-Type: application/json" \
-o /tmp/tina-reset.json
cat /tmp/tina-reset.json
echo "Waiting 60s for TinaCloud to re-index..."
sleep 60
env:
TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }}
TINA_TOKEN: ${{ secrets.TINA_TOKEN }}
- run: npm run build
env:
TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }}
TINA_TOKEN: ${{ secrets.TINA_TOKEN }}
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Setup SSH
run: |
mkdir -p ~/.ssh
printf '%s\n' "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
ssh-keyscan -p 1220 57.128.160.249 >> ~/.ssh/known_hosts 2>/dev/null
- name: Deploy to server
run: |
rsync -avz --delete \
--exclude='blog/' \
-e "ssh -p 1220 -i ~/.ssh/id_deploy" \
dist/ ubuntu@57.128.160.249:/opt/00-infrastructure/Website/website/dist/
rsync -avz \
-e "ssh -p 1220 -i ~/.ssh/id_deploy" \
server/nginx.conf ubuntu@57.128.160.249:/opt/00-infrastructure/Website/website/nginx.conf
ssh -p 1220 -i ~/.ssh/id_deploy ubuntu@57.128.160.249 \
"cd /opt/00-infrastructure/Website/website && docker compose restart web"