Skip to content

Avoid running action more than once when push to a PR #1886

Avoid running action more than once when push to a PR

Avoid running action more than once when push to a PR #1886

Workflow file for this run

name: build
on: [push, pull_request]
jobs:
test:
name: Build, lint, and test on Node.js ${{ matrix.node }}
# Prevent the action running twice when the event is both a push and pull request
if: github.event_name != 'push' || github.event_name == 'push && !github.event.pull_request

Check failure on line 9 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / build

Invalid workflow file

The workflow is not valid. .github/workflows/build.yml (Line: 9, Col: 9): Unexpected symbol: ''push && !github.event.pull_request'. Located at position 53 within expression: github.event_name != 'push' || github.event_name == 'push && !github.event.pull_request
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
steps:
- uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: npm
- name: Install dependencies
run: npm ci
# Running this after `npm ci` because `npm ci` removes `node_modules`:
- name: Download Turborepo cache
uses: actions/cache@v3
with:
path: node_modules/.cache/turbo
key: ${{ runner.os }}-node-${{ matrix.node }}-turbo-${{ hashFiles('node_modules/.cache/turbo') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-turbo-
- name: Check types
run: npm run tsc
- name: Build packages
run: npm run build
- name: Run tests
run: npm run test -- --ci --coverage --maxWorkers=2 --reporters=default --reporters=github-actions