CI #1916
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: CI | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */3 * * *' # Build and deploy every 3 hours. | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
paths-ignore: | |
- README.md | |
push: | |
branches: | |
- main | |
- 'renovate/**' | |
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 | |
if: github.event_name != 'schedule' | |
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 | |
# Check if the event is not triggered by a fork | |
env: | |
SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
steps: | |
- uses: taiki-e/checkout-action@v1 | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
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 | |
if: env.SITE_ID | |
run: pnpm install -g [email protected] | |
# https://www.raulmelo.me/en/blog/deploying-netlify-github-actions-guide | |
- name: Deploy to Netlify | |
id: netlify_deploy | |
if: env.SITE_ID | |
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.SITE_ID && github.event_name == 'pull_request' | |
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.SITE_ID && github.event_name == 'pull_request' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ github.event.number }} | |
body: 'Preview URL: ${{ steps.url_preview.outputs.NETLIFY_PREVIEW_URL }}' |