This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
64 lines (63 loc) · 1.86 KB
/
build-and-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
name: Build and deploy to nais
on:
workflow_call:
inputs:
BUILD_MODE:
required: true
type: string
NAIS_VARS:
required: true
type: string
IMAGE_NAME:
required: true
type: string
CLUSTER:
required: true
type: string
jobs:
build_and_deploy:
name: Build and deploy
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
env:
image: ghcr.io/${{ github.repository }}:${{ inputs.IMAGE_NAME }}-${{ github.sha }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
- name: Install dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Run tests
run: npm test
- name: Build application
run: npm run build-${{ inputs.BUILD_MODE }}
- name: Login to Docker registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
run: |
docker build -t ${{ env.image }} .
docker push ${{ env.image }}
- name: Push release-image as latest
if: ${{ startsWith(inputs.IMAGE_NAME, 'release') }}
run: |
docker tag ${{ env.image }} ghcr.io/${{ github.repository }}:latest
docker push ghcr.io/${{ github.repository }}:latest
- uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: ${{ inputs.CLUSTER }}
RESOURCE: .nais/config.yaml
VAR: image=${{ env.image }},BUILD_ID=${{ github.sha }}
VARS: ${{ inputs.NAIS_VARS }}