Skip to content

Commit

Permalink
ci: Publish to Cloudflare Pages to preview PR
Browse files Browse the repository at this point in the history
  • Loading branch information
YDX-2147483647 committed Apr 15, 2024
1 parent a64cd4d commit 7c4c9e9
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
# https://squidfunk.github.io/mkdocs-material/publishing-your-site/#with-github-actions
# https://www.mkdocs.org/user-guide/deploying-your-docs/#other-providers
# https://github.com/actions/starter-workflows/blob/main/pages/
name: build

on:
push:
branches:
- main
paths-ignore:
- '.vscode/**'
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# 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
Expand Down Expand Up @@ -50,6 +39,8 @@ jobs:
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:
Expand All @@ -76,12 +67,43 @@ jobs:
- 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 }}

0 comments on commit 7c4c9e9

Please sign in to comment.