.github/workflows/publish.yml
name: publish
on:
push:
branches:
- 'master'
- 'release/**'
paths:
- 'index.js'
- 'modules/**'
- 'data/**'
- 'docs/**'
- 'package.json'
jobs:
# scan code using CodeQL
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language:
- 'javascript'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: npm i
- name: Test
run: npm test
env:
INIT_CLIENT_OPTS: ${{ secrets.INIT_CLIENT_OPTS }}
generate-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v2
with:
git_user_signingkey: true
git_commit_gpgsign: true
env:
GPG_PRIVATE_KEY: ${{ secrets.KASKADI_BOT_GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.KASKADI_BOT_GPG_PRIVATE_PASSPHRASE }}
- name: Generate documentation
uses: kaskadi/action-generate-docs@master
with:
type: package
template: docs/template.md
publish:
runs-on: ubuntu-latest
needs: [analyze, test, generate-docs]
if: github.repository != 'kaskadi/template-npm-pkg' # this is done to skip publish workflow if in template (because the package does not exist and therefore this would fail)
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: Pull latest commit
run: |
git config pull.rebase false
git pull
- name: Install dependencies
run: npm i
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}