Merge branch 'main' into own-main #234
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, dev ] | |
tags: [ "*" ] | |
pull_request: | |
branches: [ main, dev ] | |
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@v3 | |
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@v3 | |
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_prod' || 'openhabGoogleAssistant_test' }} | |
runtime: nodejs18 | |
source_dir: ./functions | |
entry_point: openhabGoogleAssistant | |
region: europe-west3 | |
timeout: 180 | |
min_instances: 0 | |
env_vars: OH_HOST=myopenhab.org,OH_PORT=443,OH_PATH=/rest/items/ |