Skip to content

fix: Build error

fix: Build error #38

Workflow file for this run

name: build-deploy
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
preview: ${{ steps.build-env.outputs.preview }}
preview-alias: ${{ steps.build-env.outputs.preview-alias }}
hostname: ${{ steps.build-env.outputs.hostname }}
steps:
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@main
- name: Determine build environment
id: build-env
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "preview=false" >> $GITHUB_OUTPUT
echo "hostname=alpha.vivliostyle.pub" >> $GITHUB_OUTPUT
else
echo "preview=true" >> $GITHUB_OUTPUT
echo "preview-alias=pr-preview-${{ github.event.number }}" >> $GITHUB_OUTPUT
echo "hostname=pr-preview-${{ github.event.number }}-vivliostyle-pub-app.vivliostyle.workers.dev" >> $GITHUB_OUTPUT
fi
- run: pnpm build
env:
VITE_APP_HOSTNAME: ${{ steps.build-env.outputs.hostname }}
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@main
- run: pnpm build
env:
VITE_APP_HOSTNAME: ${{ needs.build.outputs.hostname }}
- name: Deploy production
if: ${{ !fromJSON(needs.build.outputs.preview) }}
run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy preview
if: ${{ fromJSON(needs.build.outputs.preview) }}
run: npx wrangler versions upload --preview-alias ${{ needs.build.outputs.preview-alias }}
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Comment preview URL
if: ${{ fromJSON(needs.build.outputs.preview) }}
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
with:
header: preview-url
message: |
🚧 Preview URL: <https://${{ needs.build.outputs.hostname }}>