ci: Publish to Cloudflare Pages to preview PR #39
This file contains 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: build | |
on: | |
push: | |
paths-ignore: | |
- '.vscode/**' | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
# https://github.com/actions/starter-workflows/blob/main/pages/ | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
compile-bot: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: Scholar-Compass/Scholar-Compass-front | |
ref: embed | |
- uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- run: pnpm install | |
- run: VITE_PUBLIC_API_END_POINT=https://api.scholarcompass.org pnpm build | |
- name: Rename to bot.js | |
run: | | |
cd out && mv $(jq '.["src/main.tsx"].file' .vite/manifest.json --raw-output) ../bot.js | |
- name: Upload bot.js | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bot.js | |
path: bot.js | |
build: | |
# https://squidfunk.github.io/mkdocs-material/publishing-your-site/#with-github-actions | |
# https://www.mkdocs.org/user-guide/deploying-your-docs/#other-providers | |
runs-on: ubuntu-latest | |
needs: compile-bot | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # mkdocs-git-* plugins need all history | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
cache: pip | |
cache-dependency-path: | | |
justfile | |
mkdocs.yml | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: just | |
- run: just bootstrap | |
- name: Download bot.js | |
uses: actions/download-artifact@v4 | |
with: | |
name: bot.js | |
path: docs/asset | |
- run: MKDOCS_ENABLE_GIT_INTEGRATION=true MKDOCS_BOT=production just build | |
- uses: actions/upload-pages-artifact@v3 | |
with: | |
path: site/ | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: site | |
path: site/ | |
deploy: | |
name: Deploy to GitHub Pages | |
if: ${{ github.ref == 'refs/heads/main' }} | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
contents: read | |
pages: write | |
# To allow deployment to GitHub Pages | |
id-token: write | |
steps: | |
- uses: actions/deploy-pages@v4 | |
id: deployment | |
publish: | |
name: Publish to Cloudflare Pages | |
environment: | |
name: cloudflare-pages | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
deployments: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: site | |
- uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: 7546e0e8b2da3fd06fff1373debbce8f | |
projectName: scholar-compass | |
directory: site/ | |
# To have GitHub Deployments triggered | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} |