Skip to content

Property query proposal. See #6. #12

Property query proposal. See #6.

Property query proposal. See #6. #12

Workflow file for this run

name: Deploy to GitHub Pages
on:
pull_request:
branches:
- main
push:
tags:
- '*'
branches:
- main
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Set version based on event type
# Pass untrusted input via intermediate environment variables. See https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
env:
UNTRUSTED_GITHUB_HEAD_REF: ${{ github.head_ref }}
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then
EDITOR_VERSION="latest"
elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/ ]]; then
EDITOR_VERSION="${{ github.ref_name }}"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
EDITOR_VERSION="${UNTRUSTED_GITHUB_HEAD_REF}"
fi
if [[ "$EDITOR_VERSION" =~ ^[a-zA-Z0-9.-]+$ ]]; then
echo "EDITOR_VERSION=$EDITOR_VERSION" >> "$GITHUB_ENV"
else
echo "Invalid EDITOR_VERSION: $EDITOR_VERSION"
exit 1
fi
- name: Set BASE_URL
run: |
echo "BASE_URL=/${{ github.event.repository.name }}/${{ env.EDITOR_VERSION }}" >> "$GITHUB_ENV"
- name: Install pnpm
run: npm install -g pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
env:
BASE_URL: ${{ env.BASE_URL }}
run: pnpm run -r build
- name: Deploy
run: pnpm deploy --filter=webapp --prod ./build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/dist
publish_branch: gh-pages-new # don't overwrite the existing gh-pages branch.
destination_dir: ${{ github.ref == 'refs/heads/main' && 'latest' || env.EDITOR_VERSION }}
- name: Post GitHub Pages URL as comment
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const url = `https://${context.repo.owner}.github.io/${context.repo.repo}/${{ env.EDITOR_VERSION }}`;
github.rest.issues.createComment({
issue_number: ${{ github.event.pull_request.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: `The changes have been deployed to GitHub Pages: ${url}`
});