Skip to content

Update dependencies #11

Update dependencies

Update dependencies #11

Workflow file for this run

name: CICD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup nodejs version
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
- name: Install dependencies
run: npm ci
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
unit-tests:
runs-on: ubuntu-latest
needs: setup
permissions:
# Required to checkout the code
contents: read
# Required by coverage generator to put a comment into the pull-request
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup node version
uses: actions/setup-node@v3
with:
node-version-file: ".node-version"
- name: Install dependencies
run: npm ci
- name: Run unit tests
run: npm run test:ci
- name: 'Report Coverage'
if: always() # Also generate the report if tests are failing
uses: davelosert/vitest-coverage-report-action@v1
deploy-to-docker:
runs-on: ubuntu-latest
needs:
- setup
- unit-tests
# - cypress-run
steps:
- name: Install curl
run: sudo apt-get install -y curl openssl
- name: Checkout code
uses: actions/checkout@v3
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v4
with:
images: joschi64/mqtt-prometheus-gateway
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
- name: Call deployment webhook if it exists
env:
url: ${{ secrets.DEPLOYMENT_WEBHOOK }}
if: ${{ env.url != '' }}
run: |
sed s/https/http/ <<< $url
curl -X POST $url