Konnorrogers/fix new lines in light editor #248
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Site | |
on: | |
push: | |
branches: | |
- main # deploy main. If your branch is `master`, you'll have to replace that throughout this file. | |
pull_request: # This will publish a site preview on every pull request, and also run the build command to test if the site is broken. | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18] | |
env: | |
PR_PATH: pull/${{github.event.number}} | |
steps: | |
- name: Comment on PR | |
uses: hasura/[email protected] | |
if: github.ref != 'refs/heads/main' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "Starting deployment of preview ⏳..." | |
- name: Set domain | |
# If you're using the default github pages url, use this instead: | |
run: echo "DOMAIN=${{ github.actor }}.github.io" >> $GITHUB_ENV | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "pnpm" | |
cache-dependency-path: | | |
pnpm-lock.yaml | |
docs/pnpm-lock.yaml | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.0" | |
rubygems: latest | |
bundler-cache: true | |
- name: Set production base URL | |
run: | | |
echo "URL=https://${{ env.DOMAIN }}" >> $GITHUB_ENV | |
echo "BASE_PATH=/${{ github.event.repository.name }}" >> $GITHUB_ENV | |
- name: Set base_path for preview if PR | |
if: github.ref != 'refs/heads/main' | |
run: echo "BASE_PATH=/${{ github.event.repository.name }}/${{ env.PR_PATH }}" >> $GITHUB_ENV | |
- name: Set base_url | |
run: echo "BASE_URL=$URL/$BASE_PATH" >> $GITHUB_ENV | |
- name: Build website | |
run: | | |
pnpm run setup | |
pnpm run build | |
pnpm run build:docs | |
pnpm run build:api | |
- name: Set username + email | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "github-actions-bot" | |
- name: Deploy with gh-pages | |
if: github.ref == 'refs/heads/main' | |
run: | | |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
pnpm exec gh-pages -d ./docs/output --dotfiles -b gh-pages -- -u "github-actions-bot <[email protected]>" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy preview with gh-pages | |
if: github.ref != 'refs/heads/main' | |
run: | | |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
pnpm exec gh-pages -d ./docs/output --dotfiles --dest "${{ env.PR_PATH }}" -b gh-pages -- -u "github-actions-bot <[email protected]>" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update comment | |
uses: hasura/[email protected] | |
if: github.ref != 'refs/heads/main' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }} ✨\n\nChanges may take a few minutes to propagate. Since this is a preview of production, content with `draft: true` will not be rendered. The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/" |