Skip to content

Revert "feat: Template" (#23) #89

Revert "feat: Template" (#23)

Revert "feat: Template" (#23) #89

Workflow file for this run

name: build-deploy
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
merge_group:
types: [checks_requested]
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
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 }}" == "${{ github.event.repository.default_branch }}" ]]; then
echo "preview=false" >> $GITHUB_OUTPUT
echo "hostname=alpha.vivliostyle.pub" >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
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
if: ${{ github.event_name == 'pull_request' || github.ref_name == github.event.repository.default_branch }}
steps:
- uses: vivliostyle/vivliostyle.pub/.github/actions/setup@main
- run: pnpm build
env:
VITE_APP_HOSTNAME: ${{ needs.build.outputs.hostname }}
- name: Deploy production
if: ${{ github.ref_name == github.event.repository.default_branch }}
run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy preview
if: ${{ github.event_name == 'pull_request' }}
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: ${{ github.event_name == 'pull_request' }}
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4
with:
header: preview-url
message: |
🚧 Preview URL: <https://${{ needs.build.outputs.hostname }}>