Skip to content

Commit

Permalink
chore: integrate github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
codenaz committed Mar 5, 2023
1 parent da7538f commit 2baaaa4
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/actions/run-tests/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Run tests"
description: "Runs the tests. Requires that the repo is checked out and gcloud credentials are set."
runs:
using: "composite"
steps:
- name: Install deps
run: npm ci
shell: bash

- name: Test
run: npm run test
shell: bash
60 changes: 60 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish to npm

on:
workflow_dispatch: {}
workflow_call:
inputs:
version:
required: true
type: string

env:
FORCE_COLOR: 1

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 15.x, 16.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Run tests
uses: ./.github/actions/run-tests

build-publish:
if: github.ref == 'refs/heads/master'

name: Publish
runs-on: ubuntu-latest
needs: test

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Install deps
run: npm ci

- name: Build project
run: npm run build

- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on:
pull_request:
types: [opened, labeled, synchronize]

env:
FORCE_COLOR: 1

jobs:
test:
name: Test
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Run tests
uses: ./.github/actions/run-tests

0 comments on commit 2baaaa4

Please sign in to comment.