Repository navigation
Merge pull request #345 from phalcon/collapse-versions-on-mobile #833
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: Deploy Documents | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| # The branch that Cloudflare Pages serves. `production` during the trial | |
| # of the new site; `gh-pages` holds the last MkDocs deployment as the | |
| # rollback. Flip the Pages production branch together with this value. | |
| DEPLOY_BRANCH: production | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: true | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| - name: Set up Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Update the new feature request list | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: pnpm run update-nfr | |
| - name: Test | |
| run: pnpm test | |
| - name: Get the fan art | |
| # The HTML comment at the top of every page. The committed | |
| # src/fanart.html is the fallback when the download fails. | |
| run: | | |
| curl -fsSL -o src/fanart.html \ | |
| https://raw.githubusercontent.com/phalcon/assets/master/phalcon/fanart-fragment.html \ | |
| || echo "Download failed, the committed fan art is used" | |
| - name: Get the sponsors | |
| # Generated into phalcon/assets by its own scheduled workflow. The | |
| # committed src/sponsors.json is the fallback when the download fails. | |
| run: | | |
| curl -fsSL -o src/sponsors.json \ | |
| https://raw.githubusercontent.com/phalcon/assets/master/phalcon/sponsors.json \ | |
| || echo "Download failed, the committed roster is used" | |
| - name: Build | |
| run: pnpm build | |
| - name: Determine the stable version | |
| id: stable | |
| run: | | |
| STABLE=$(node -e "import('./src/lib/site.mjs').then((m) => console.log(m.STABLE_VERSION))") | |
| echo "Stable version: ${STABLE}" | |
| echo "version=${STABLE}" >> "$GITHUB_OUTPUT" | |
| - name: Publish to the deploy branch | |
| run: | | |
| git config user.name niden | |
| git config user.email nikos@niden.net | |
| git fetch --no-tags --prune --depth=1 origin "+refs/heads/${DEPLOY_BRANCH}:refs/remotes/origin/${DEPLOY_BRANCH}" | |
| git worktree add ../deploy "origin/${DEPLOY_BRANCH}" | |
| rsync -a --delete --exclude .git dist/ ../deploy/ | |
| touch ../deploy/.nojekyll | |
| git -C ../deploy add -A | |
| git -C ../deploy commit -m "Deployed ${GITHUB_SHA::7}" || echo "No changes to deploy" | |
| git -C ../deploy push origin "HEAD:${DEPLOY_BRANCH}" | |
| - name: Point Cloudflare /latest at the stable version | |
| env: | |
| CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | |
| CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }} | |
| CF_RULESET_ID: ${{ secrets.CF_RULESET_ID }} | |
| CF_RULE_ID: ${{ secrets.CF_RULE_ID }} | |
| STABLE: ${{ steps.stable.outputs.version }} | |
| run: | | |
| echo "Pointing /latest -> /${STABLE} at Cloudflare" | |
| curl -sS --fail-with-body -X PATCH \ | |
| "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/rulesets/${CF_RULESET_ID}/rules/${CF_RULE_ID}" \ | |
| -H "Authorization: Bearer ${CF_API_TOKEN}" \ | |
| -H "Content-Type: application/json" \ | |
| --data @- <<JSON | |
| { | |
| "action": "redirect", | |
| "description": "Documentation Latest", | |
| "enabled": true, | |
| "expression": "(http.request.full_uri wildcard r\"https://docs.phalcon.io/latest/*\")", | |
| "action_parameters": { | |
| "from_value": { | |
| "status_code": 301, | |
| "target_url": { | |
| "expression": "wildcard_replace(http.request.full_uri, r\"https://docs.phalcon.io/latest/*\", r\"https://docs.phalcon.io/${STABLE}/\${1}\")" | |
| }, | |
| "preserve_query_string": true | |
| } | |
| } | |
| } | |
| JSON |