-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (113 loc) · 3.7 KB
/
cicd.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
name: Build, Test and Deploy
env:
# Release name must match "repo" value in docker/*-values.yml
RELEASE_NAME: solstice-docs
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
types: [opened, reopened, synchronize]
jobs:
context:
runs-on: ubuntu-20.04
outputs:
commit_hash: ${{ steps.context.outputs.commit_hash }}
git_repo_branch: ${{ steps.context.outputs.git_repo_branch }}
image_tag: ${{ steps.context.outputs.image_tag }}
steps:
- name: Set up Context
id: context
uses: uw-it-aca/actions/cicd-context@main
with:
release_name: ${{ env.RELEASE_NAME }}
build:
runs-on: ubuntu-20.04
needs: context
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-$(echo ${{ hashFiles('Dockerfile') }} | head -c 16)
restore-keys: |
${{ runner.os }}-buildx-
- name: Build App Image
uses: docker/build-push-action@v3
with:
context: .
target: app-container
tags: ${{ needs.context.outputs.image_tag }}
push: false
load: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Push Image to GCR
if: github.event_name == 'push'
uses: uw-it-aca/actions/gcr-push@main
with:
image_tag: ${{ needs.context.outputs.image_tag }}
gcp_json_key: ${{ secrets.GCP_JSON_KEY }}
test:
runs-on: ubuntu-20.04
needs: build
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install packages
run: npm install
- name: Run Vitest coverage
run: npm run coverage
- name: Post coverage data to Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint with ESLint
run: npm run eslint
- name: Lint with StyleLint
run: npm run stylelint
deploy:
if: github.event_name == 'push'
needs: [context, build]
outputs:
context: ${{ steps.context.outputs.context }}
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Deployment Pipeline
if: >-
contains(fromJSON('["main", "develop"]'),
needs.context.outputs.git_repo_branch)
uses: uw-it-aca/actions/cicd-deploy@main
with:
release_name: ${{ env.RELEASE_NAME }}
commit_hash: ${{ needs.context.outputs.commit_hash }}
git_repo_branch: ${{ needs.context.outputs.git_repo_branch }}
gh_auth_token: ${{ secrets.GH_AUTH_TOKEN }}
- name: 'Surface context from executed build step'
id: context
shell: bash
run: echo "context=$(< ${CONTEXT_FILENAME})" >> $GITHUB_OUTPUT
housekeeping:
if: github.event_name == 'push'
needs: [context, build, deploy]
runs-on: ubuntu-20.04
steps:
- name: House Keeping
uses: uw-it-aca/actions/cicd-housekeeping@main
with:
release_name: ${{ env.RELEASE_NAME }}
gh_auth_token: ${{ secrets.GH_AUTH_TOKEN }}
registry_password: ${{ secrets.GCP_JSON_KEY }}
context: ${{ needs.deploy.outputs.context }}
prune_flux_preserve_count: 2 # this isn't in the example, is it needed?