This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
94 lines (87 loc) · 2.69 KB
/
build-deploy.yaml
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
name: Build and deploy
on: [ push ]
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
concurrency:
group: build-deploy-on-${{ github.ref }}
cancel-in-progress: true
jobs:
compile-test-and-build:
name: Build and run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
registry-url: https://npm.pkg.github.com/
cache: 'yarn'
cache-dependency-path: |
yarn.lock
server/yarn.lock
- name: Install dependencies for server
run: cd server && yarn install --frozen-lockfile --prefer-offline
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Install dependencies
run: yarn install --frozen-lockfile --prefer-offline
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Run tests
run: yarn test
- name: Build application
run: yarn build
env:
CI: false
- name: Login to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the Docker image
run: |
docker build . -t ${IMAGE}
docker push ${IMAGE}
deploy-to-dev-gcp:
name: Deploy to dev-gcp
if: github.ref == 'refs/heads/session-metric-v2'
needs: compile-test-and-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/dev-gcp.yaml
PRINT_PAYLOAD: true
deploy-to-dev-gcp-ekstern:
name: Deploy to dev-gcp-ekstern
if: github.ref == 'refs/heads/master'
needs: compile-test-and-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/dev-gcp-ekstern.yaml
PRINT_PAYLOAD: true
deploy-to-prod-gcp:
name: Deploy to prod-gcp
if: github.ref == 'refs/heads/master'
needs: compile-test-and-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/prod-gcp.yaml
PRINT_PAYLOAD: true