Skip to content

chore(ci): integrate Cloudflare Pages action #84

chore(ci): integrate Cloudflare Pages action

chore(ci): integrate Cloudflare Pages action #84

Workflow file for this run

name: ci
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- name: Comment deploy start
if: ${{ github.event.workflow_run.event != 'push' }}
uses: mshick/add-pr-comment@v2
with:
message-id: cloudflare-deploy
message: |
### <span aria-hidden="true">🚧</span> Deploy Preview building...
| 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 }} |
---
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: "wasm32-unknown-unknown,x86_64-unknown-linux-gnu"
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-node@v4
name: Setup Node.js
with:
node-version: "20"
- name: Enable corepack
run: corepack enable
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Run tests
run: cargo test --workspace --exclude gb-wasm --target x86_64-unknown-linux-gnu
- name: Lint
run: cargo clippy --target wasm32-unknown-unknown
- name: Build WASM
working-directory: ./crates/gb-wasm
run: wasm-pack build --release --out-dir npm --target web
- name: Install dependencies for web app
working-directory: ./app/gameboy
run: corepack pnpm install --frozen-lockfile
- name: Build web app
working-directory: ./app/gameboy
run: corepack pnpm run build
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: cloudflare-publish
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: gbplay
directory: dist
workingDirectory: app/gameboy
wranglerVersion: "3"
- name: Comment deploy URL
uses: mshick/add-pr-comment@v2
if: ${{ github.event.workflow_run.event != 'push' }}
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-publish.outputs.url }}](${{ steps.cloudflare-publish.outputs.url }}) |
|<span aria-hidden="true">🌳</span> Environment | ${{ steps.cloudflare-publish.outputs.environment }} |
---