This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (88 loc) · 2.86 KB
/
main.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
95
name: main
on: push
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
jobs:
build:
name: Checkout code and create docker tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Use Node
uses: actions/setup-node@v2
with:
node-version: '16.14.2'
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: |
npm install
- name: Run tests
run: |
npm run test
- name: Build
run: |
npm run build
- name: Login to GitHub Container Registry
uses: docker/login-action@ab80d026d4753220c4243394c07c7d80f9638d06 # Use commit-sha1 instead of tag for security concerns
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish Docker image
run: |
docker build --tag ${IMAGE} .
docker push ${IMAGE}
echo ${IMAGE}
deploy-dev:
if: github.ref == 'refs/heads/master'
name: Deploy to dev-gcp
needs: 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
RESOURCE: naiserator-dev.yaml
# Notify Slack
- name: Unsuccessful deploy notification dev
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TITLE: 'Unsuccesful deployment - `dev` :crying_cat_face:'
SLACK_MESSAGE: '`${{ github.event.repository.name }}` failed to deploy to dev.'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: commit
SLACK_COLOR: ${{ job.status }}
deploy-prod:
if: github.ref == 'refs/heads/master'
name: Deploy to prod-gcp
needs: deploy-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: naiserator-prod.yaml
# Notify Slack
- name: Unsuccessful deploy notification prod
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TITLE: 'Unsuccesful deployment :crying_cat_face:'
SLACK_MESSAGE: '`${{ github.event.repository.name }}` failed to deploy to prod.'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
MSG_MINIMAL: commit
SLACK_COLOR: ${{ job.status }}