Merge pull request #541 from openhab/dependabot/npm_and_yarn/types/je… #839
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD | |
on: | |
push: | |
branches: [ main ] | |
tags: [ "*" ] | |
pull_request: | |
branches: [ main ] | |
release: | |
types: [ published ] | |
jobs: | |
markdown-checks: | |
if: github.event_name == 'pull_request' | |
name: Markdown Checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Lint Markdown files | |
uses: nosborn/[email protected] | |
with: | |
files: . | |
- name: Check spelling | |
uses: reviewdog/action-misspell@v1 | |
with: | |
github_token: ${{ secrets.github_token }} | |
locale: 'US' | |
fail_on_error: true | |
filter_mode: 'nofilter' | |
exclude: '*.json' | |
- name: Check style and grammar | |
uses: reviewdog/action-languagetool@v1 | |
with: | |
github_token: ${{ secrets.github_token }} | |
unit-testing: | |
name: Unit Testing | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Run linting | |
run: npm run lint | |
- name: Run tests | |
run: npm run test-ci | |
- name: Upload Test Coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage | |
path: coverage/ | |
code-analysis: | |
name: Code Analysis | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: javascript | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
deployment: | |
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release' | |
name: Install and Deploy | |
runs-on: ubuntu-latest | |
needs: [unit-testing, code-analysis] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
cache-dependency-path: 'functions/package-lock.json' | |
- name: Install dependencies | |
working-directory: ./functions | |
run: npm ci | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/[email protected] | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Deploy to Google Cloud Functions | |
uses: google-github-actions/[email protected] | |
with: | |
name: ${{ github.event_name == 'release' && 'openhabGoogleAssistant' || 'openhabGoogleAssistant_test' }} | |
runtime: nodejs18 | |
source_dir: ./functions | |
entry_point: openhabGoogleAssistant | |
region: us-central1 | |
timeout: 180 | |
memory_mb: 256MB | |
min_instances: 1 | |
max_instances: 20 | |
env_vars: OH_HOST=myopenhab.org,OH_PORT=443,OH_PATH=/rest/items/ |