🥬 Refresh Content #208
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: 🥬 Refresh Content | |
| on: | |
| # Runs after the Deploy workflow finishes, rather than on its own `push`, | |
| # so the refresh-cache POST always lands on the instance that was actually | |
| # just deployed instead of racing the (much slower) deploy job and hitting | |
| # the old server. See app/utils/mdx.server.ts CACHE_VERSION for the other | |
| # half of this fix (schema changes bust cache without needing a refresh). | |
| workflow_run: | |
| workflows: ['🚀 Deploy'] | |
| types: | |
| - completed | |
| jobs: | |
| refresh: | |
| name: 🥬 Refresh Content | |
| runs-on: ubuntu-latest | |
| # workflow_run also fires for PR runs of Deploy (lint-only, deploy job | |
| # skipped) — only refresh after a real push-triggered deploy succeeds. | |
| if: > | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && contains(fromJSON('["main", | |
| "dev"]'), github.event.workflow_run.head_branch) | |
| steps: | |
| - name: ⬇️ Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| fetch-depth: '50' | |
| - name: ⎔ Setup node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.22.0 | |
| - name: 🥬 Refresh Content | |
| run: node ./other/refresh-changed-content.cjs "$DEPLOYED_SHA" | |
| env: | |
| REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }} | |
| DEPLOYED_SHA: ${{ github.event.workflow_run.head_sha }} | |
| # workflow_run always sees GITHUB_REF_NAME as the default branch, | |
| # so pass through the branch that was actually deployed — utils.cjs | |
| # uses this to pick the staging vs. production hostname. | |
| GITHUB_REF_NAME: ${{ github.event.workflow_run.head_branch }} |