Skip to content

Commit

Permalink
chore: add main.yml to github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
tribiec committed Jan 24, 2024
1 parent 998096c commit a152f25
Showing 1 changed file with 51 additions and 22 deletions.
73 changes: 51 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,64 @@
name: Build
name: Node.js CI

on:
workflow_dispatch:
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- '**'
push:
branches:
- main
- develop
- feat/*
- bug/*
- chore/*
- master
tags:
- '*'

jobs:

SonarCloud:
build:
runs-on: ubuntu-latest
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:
fetch-depth: 0
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Build
run: npm run build

- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build-and-publish:
if: github.ref == 'refs/heads/master' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['11.x']
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
args: >
-Dsonar.branch.name=${{ env.GITHUB_REF_NAME }}
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- 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: Build
run: npm run build
- name: npm publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

0 comments on commit a152f25

Please sign in to comment.