1
+ name : Test, build, push and deploy
2
+ on : push
3
+ env :
4
+ IMAGE_TAG : ${{ github.sha }}
5
+ IMAGE : docker.pkg.github.com/${{ github.repository }}/beslutteroversikt
6
+ PRINT_PAYLOAD : true
7
+ jobs :
8
+ test :
9
+ name : Run tests
10
+ runs-on : ubuntu-latest
11
+ if : github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/master'
12
+ steps :
13
+ - name : Checkout
14
+ uses : actions/checkout@v1
15
+ - name : Setup node
16
+ uses : actions/setup-node@v1
17
+ with :
18
+ node-version : ' 12.x'
19
+ - name : Install dependencies
20
+ run : npm ci
21
+ - name : Run tests
22
+ run : npm run test
23
+
24
+ test-build-and-push :
25
+ name : Test, build and push
26
+ runs-on : ubuntu-latest
27
+ if : github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/master'
28
+ steps :
29
+ - name : Checkout
30
+ uses : actions/checkout@v1
31
+ - name : Setup node
32
+ uses : actions/setup-node@v1
33
+ with :
34
+ node-version : ' 12.x'
35
+ - name : Install dependencies
36
+ run : npm ci
37
+ - name : Build application
38
+ run : npm run build
39
+ - name : Build and push Docker image
40
+ env :
41
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42
+ run : |
43
+ docker build -t ${IMAGE}:${IMAGE_TAG} .
44
+ docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
45
+ docker push ${IMAGE}:${IMAGE_TAG}
46
+
47
+ update-gh-pages :
48
+ name : Update GitHub pages
49
+ runs-on : ubuntu-latest
50
+ if : github.ref == 'refs/heads/dev'
51
+ steps :
52
+ - name : Checkout
53
+ uses : actions/checkout@v1
54
+ - name : Setup node
55
+ uses : actions/setup-node@v1
56
+ with :
57
+ node-version : ' 12.x'
58
+ - name : Install dependencies
59
+ run : npm ci
60
+ - name : Build mock application
61
+ run : npm run build:mock
62
+ - name : Update GitHub pages
63
+
64
+ env :
65
+ ACTIONS_DEPLOY_KEY : ${{ secrets.ACTIONS_DEPLOY_KEY }}
66
+ PUBLISH_BRANCH : gh-pages
67
+ PUBLISH_DIR : build
68
+
69
+ deploy-q0 :
70
+ name : Deploy application to Q0
71
+ if : github.ref == 'refs/heads/dev'
72
+ needs : test-build-and-push
73
+ runs-on : ubuntu-latest
74
+ steps :
75
+ - name : Checkout
76
+ uses : actions/checkout@v1
77
+ - name : Deploy application
78
+ uses : nais/deploy/actions/deploy@v1
79
+ env :
80
+ APIKEY : ${{ secrets.NAIS_DEPLOY_APIKEY }}
81
+ CLUSTER : dev-fss
82
+ RESOURCE : nais-q.yaml
83
+ VAR : version=${{ env.IMAGE_TAG }},namespace=q0
84
+ deploy-q1 :
85
+ name : Deploy application to Q1
86
+ if : github.ref == 'refs/heads/dev'
87
+ needs : test-build-and-push
88
+ runs-on : ubuntu-latest
89
+ steps :
90
+ - name : Checkout
91
+ uses : actions/checkout@v1
92
+ - name : Deploy application
93
+ uses : nais/deploy/actions/deploy@v1
94
+ env :
95
+ APIKEY : ${{ secrets.NAIS_DEPLOY_APIKEY }}
96
+ CLUSTER : dev-fss
97
+ RESOURCE : nais-q.yaml
98
+ VAR : version=${{ env.IMAGE_TAG }},namespace=q1
99
+ deploy-prod :
100
+ name : Deploy application to prod
101
+ if : github.ref == 'refs/heads/master'
102
+ needs : test-build-and-push
103
+ runs-on : ubuntu-latest
104
+ steps :
105
+ - name : Checkout
106
+ uses : actions/checkout@v1
107
+ - name : Deploy application
108
+ uses : nais/deploy/actions/deploy@v1
109
+ env :
110
+ APIKEY : ${{ secrets.NAIS_DEPLOY_APIKEY }}
111
+ CLUSTER : prod-fss
112
+ RESOURCE : nais.yaml
113
+ VAR : version=${{ env.IMAGE_TAG }}
114
+ release-dev :
115
+ name : Create dev release
116
+ needs : [deploy-q0, deploy-q1]
117
+ runs-on : ubuntu-latest
118
+ steps :
119
+ - name : Create release
120
+ uses : actions/create-release@v1
121
+ env :
122
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
123
+ with :
124
+ tag_name : release/dev@${{ env.IMAGE_TAG }}
125
+ release_name : Release to dev
126
+ prerelease : true
127
+ release-prod :
128
+ name : Create prod release
129
+ needs : deploy-prod
130
+ runs-on : ubuntu-latest
131
+ steps :
132
+ - name : Create release
133
+ uses : actions/create-release@v1
134
+ env :
135
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
136
+ with :
137
+ tag_name : release/prod@${{ env.IMAGE_TAG }}
138
+ release_name : Release to prod
139
+ prerelease : false
0 commit comments