-
Notifications
You must be signed in to change notification settings - Fork 6
108 lines (93 loc) · 2.91 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
permissions:
packages: write
contents: read
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 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