Skip to content

Preview deployments #29

Preview deployments

Preview deployments #29

Workflow file for this run

name: Build and deploy
on:
push:
branches: [ "main" ]
pull_request:
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Restore cache
uses: Swatinem/rust-cache@v2
- name: Setup mdBook
run: cargo install mdbook mdbook-mermaid
- name: Setup Pages
id: pages
uses: actions/configure-pages@v4
- name: Build with mdBook
run: mdbook build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./book
deploy-preview:
name: Deploy preview
runs-on: ubuntu-latest
if: github.event_name != 'push'
needs: build
permissions:
contents: read
steps:
- name: Download WEB artefact
uses: actions/download-artifact@v4
with:
name: github-pages
- run: ls -lah
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: cloudflare
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: biip-docs
directory: web-build
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
wranglerVersion: '3'
- name: Comment deploy url
uses: mshick/add-pr-comment@v2
with:
message-id: cloudflare-deploy
message: |
### <span aria-hidden="true">✅</span> Deploy Preview ready!
| Name | Link |
|---------------------------------|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ${{ github.sha }} |
|<span aria-hidden="true">🔍</span> Latest deploy log | ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
|<span aria-hidden="true">😎</span> Deploy Preview Url | [${{ steps.cloudflare.outputs.url }}](${{ steps.cloudflare.outputs.url }}) |
|<span aria-hidden="true">🌳</span> Environment | ${{ steps.cloudflare.outputs.environment }} |
---
deploy:
name: Deploy
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'
permissions:
contents: read
actions: read
pages: write
id-token: write
concurrency:
group: pages
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4