Cron Rebuild Site #1178
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cron Rebuild Site | |
| on: | |
| schedule: | |
| # Once per day at midnight UTC — rebuilds the site to pick up new UGC workflows | |
| # for search index, sitemap, filter pages, and pre-rendered detail pages. | |
| # Only approved workflows are included in the production build. | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| concurrency: | |
| group: deploy-prod | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| rebuild: | |
| runs-on: ubuntu-latest | |
| env: | |
| SKIP_AI_GENERATION: 'true' | |
| PUBLIC_POSTHOG_KEY: phc_iKfK86id4xVYws9LybMje0h44eGtfwFgRPIBehmy8rO | |
| PUBLIC_GA_MEASUREMENT_ID: ${{ secrets.PUBLIC_GA_MEASUREMENT_ID }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup | |
| uses: ./.github/actions/site-setup | |
| - name: Restore content cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: site/.content-cache | |
| key: content-cache-cron-prod-${{ hashFiles('templates/**', 'site/src/**') }} | |
| restore-keys: | | |
| content-cache-cron-prod- | |
| - name: Sync templates | |
| run: pnpm run sync | |
| working-directory: site | |
| - name: Build Astro site | |
| run: pnpm run build | |
| working-directory: site | |
| env: | |
| PUBLIC_HUB_API_URL: ${{ secrets.HUB_API_URL_PRODUCTION }} | |
| PUBLIC_COMFY_CLOUD_URL: ${{ secrets.COMFY_CLOUD_URL_PRODUCTION }} | |
| PUBLIC_APPROVED_ONLY: 'true' | |
| - name: Deploy to Vercel | |
| working-directory: site | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| run: | | |
| stdout_file="$RUNNER_TEMP/vercel-production.stdout" | |
| stderr_file="$RUNNER_TEMP/vercel-production.stderr" | |
| site_output_dir="$GITHUB_WORKSPACE/site/.vercel/output" | |
| root_output_dir="$GITHUB_WORKSPACE/.vercel/output" | |
| if [ ! -d "$site_output_dir" ]; then | |
| echo "Expected prebuilt output in $site_output_dir" >&2 | |
| exit 1 | |
| fi | |
| mkdir -p "$GITHUB_WORKSPACE/.vercel" | |
| rm -rf "$root_output_dir" | |
| cp -R "$site_output_dir" "$root_output_dir" | |
| if npx vercel@latest deploy --cwd "$GITHUB_WORKSPACE" --prebuilt --prod --yes \ | |
| --token="$VERCEL_TOKEN" >"$stdout_file" 2>"$stderr_file"; then | |
| cat "$stderr_file" >&2 | |
| cat "$stdout_file" | |
| else | |
| cat "$stderr_file" >&2 | |
| cat "$stdout_file" | |
| exit 1 | |
| fi |