Skip to content

UPDATE: clean up code and test #1103

UPDATE: clean up code and test

UPDATE: clean up code and test #1103

Workflow file for this run

name: Build, push, and deploy
on:
push:
branches:
- '*'
pull_request:
branches:
- main
release:
types:
- created
env:
TEST_PROJECT_KEY: ${{ secrets.TEST_PROJECT_KEY }}
IMAGE: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}:${{ github.sha }}
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Cache Node Modules
uses: actions/cache@v2
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-
- name: Install Node Modules
run: npm ci --ignore-scripts --no-optional --prefer-offline --no-audit
- name: Prep Test Environment
run: mkdir -p secrets && npm run ensure-test-features
- name: Set up Docker Compose # Can bring up kafka and other containers
run: npm run all-up
- name: Run Unit Tests # Running unit tests
run: npm test
# - name: Run Blackbox Tests # Running test against the docker image
# run: npm run blackbox
- name: Login to DockerHub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
uses: docker/build-push-action@v3
with:
push: true
tags: ${{env.IMAGE}}
context: .
# # Deployer til labs-gcp på alle merges til master
# deploy-labs-gcp:
# name: Deploy to nais labs-gcp
# needs: test
# if: github.ref == 'refs/heads/main' && github.event_name != 'release'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: nais/deploy/actions/deploy@v1
# env:
# APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
# CLUSTER: labs-gcp
# RESOURCE: .nais/labs-gcp.yaml
# Deployer til dev-gcp på alle merges til main
deploy-dev-gcp:
name: Deploy to nais dev-gcp
needs: test
if: github.ref == 'refs/heads/main' && github.event_name != 'release'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/dev-gcp.yaml
# Deployer til Prod-GCP på "release" fra github
deploy-prod-gcp:
name: Deploy to nais prod-gcp
needs: test
if: github.event_name == 'release'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: .nais/prod-gcp.yaml
- name: deploy alerts to prod-gcp
uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: .nais/alerts.yaml