Skip to content

ci: deploy to netlify #20

ci: deploy to netlify

ci: deploy to netlify #20

Workflow file for this run

name: CI
on:
pull_request:
types:
- opened
- synchronize
paths-ignore:
- README.md
push:
branches:
- main
paths-ignore:
- README.md
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
jobs:
check-typos:
name: Check typos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master
with:
files: .
wasm:
name: Build Wasm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: oxc-project/oxc
ref: main
- uses: Boshen/setup-rust@main
with:
save-cache: ${{ github.ref_name == 'main' }}
tools: wasm-pack,just
- run: just build-wasm
- uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: wasm
path: npm/oxc-wasm
build:
needs: wasm
name: Build Playground
runs-on: ubuntu-latest
steps:
- uses: taiki-e/checkout-action@v1
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- run: pnpm install --frozen-lockfile
# Download after to invalidate the version from pnpm cache
- uses: actions/download-artifact@v4
with:
merge-multiple: true
name: wasm
path: ../oxc/npm/oxc-wasm
- run: pnpm run build
- name: Install Netlify
run: pnpm install -g [email protected]
# https://www.raulmelo.me/en/blog/deploying-netlify-github-actions-guide
- name: Deploy to Netlify
id: netlify_deploy
run: |
prod_flag=""
if [ "${{ github.ref_name }}" = "main" ]; then prod_flag="--prod"; fi
netlify deploy \
--dir dist \
--site ${{ secrets.NETLIFY_SITE_ID }} \
--auth ${{ secrets.NETLIFY_API_TOKEN }} \
$prod_flag \
--json \
> deploy_output.json
- name: Generate URL Preview
id: url_preview
if: ${{ env.github_refname != 'main' }}
run: |
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' deploy_output.json)
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> $GITHUB_OUTPUT
- uses: peter-evans/create-or-update-comment@v4
if: ${{ env.github_refname != 'main' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.number }}
body: "Preview URL: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}"