Skip to content

chore: add conditions to optimze workflow #2

chore: add conditions to optimze workflow

chore: add conditions to optimze workflow #2

Workflow file for this run

name: Node.js CI
on:
push:
branches:
- '**'
tags:
- '*'
pull_request:
branches:
- '**'
jobs:
test:
runs-on: ubuntu-18.04
strategy:
matrix:
node-version: [11.x, 12.x, 13.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
build-and-publish:
if: github.ref == 'refs/heads/master' && startsWith(github.ref, 'refs/tags/')
needs: test
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: '11.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: npm publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}