generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (139 loc) · 4.87 KB
/
pr-open.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
143
144
145
146
147
148
149
150
name: Pull Request
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
builds:
name: Builds
uses: ./.github/workflows/_build.yml
strategy:
matrix:
component: [backend, frontend]
include:
- component: backend
triggers: ('backend/')
- component: frontend
triggers: ('frontend/')
secrets:
gh_token: ${{ secrets.GHCR_TOKEN }}
with:
component: ${{ matrix.component }}
img_build: ${{ github.event.number }}
img_fallback: test
triggers: ${{ matrix.triggers }}
tests:
name: Unit Tests
uses: ./.github/workflows/_code-cov.yml
strategy:
matrix:
component: [backend]
secrets:
gh_token: ${{ secrets.GHCR_TOKEN }}
with:
component: ${{ matrix.component }}
lcov_file: ${{ matrix.component }}/coverage/lcov.info
test_cmd: npm run test:cov
#sonarcloud:
# name: Static Analysis
# needs:
# - tests
# runs-on: ubuntu-22.04
# steps:
# # Disable shallow clone for SonarCloud analysis
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Get backend coverage from cache
# uses: actions/cache@v3
# with:
# path: backend/coverage
# key: coverage-backend-${{ github.run_number }}
# restore-keys: |
# coverage-backend-
# - name: Get frontend coverage from cache
# uses: actions/cache@v3
# with:
# path: frontend/coverage
# key: coverage-frontend-${{ github.run_number }}
# restore-keys: |
# coverage-frontend-
# - name: SonarCloud Scan
# uses: SonarSource/sonarcloud-github-action@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# with:
# args: >
# -Dsonar.exclusions=**/test/**,.github/**/*,*.md
# -Dsonar.organization=bcgov-sonarcloud
# -Dsonar.javascript.lcov.reportPaths=backend/coverage/lcov.info,frontend/coverage/lcov.info
# -Dsonar.cobertura.reportPaths=backend/coverage/cobertura-coverage.xml,frontend/coverage/cobertura-coverage.xml
# -Dsonar.project.monorepo.enabled=true
# -Dsonar.projectKey=${{ github.event.repository.name }}
# -Dsonar.sources=backend,frontend
# -Dsonar.tests=backend/test,frontend/test
deploys:
name: Deploys
needs:
- builds
# If any of the prerequs created a build, then deploy
if: contains(needs.*.outputs.build, 'true')
uses: ./.github/workflows/_deploy.yml
strategy:
matrix:
component: [backend, database, frontend]
include:
- component: database
overwrite: false
template_file: .github/openshift/deploy.database.yml
template_vars: -p ZONE=${{ github.event.number }}
- component: backend
overwrite: true
template_file: .github/openshift/deploy.backend.yml
template_vars: -p ZONE=${{ github.event.number }} -p PROMOTE=${{ github.repository }}:${{ github.event.number }}-backend
- component: frontend
overwrite: true
template_file: .github/openshift/deploy.frontend.yml
template_vars: -p ZONE=${{ github.event.number }} -p PROMOTE=${{ github.repository }}:${{ github.event.number }}-frontend
secrets:
oc_namespace: ${{ secrets.OC_NAMESPACE }}
oc_server: ${{ secrets.OC_SERVER }}
oc_token: ${{ secrets.OC_TOKEN }}
with:
component: ${{ matrix.component }}
overwrite: ${{ matrix.overwrite }}
template_file: ${{ matrix.template_file }}
template_vars: ${{ matrix.template_vars }}
post-deploy:
name: Post-deploy
needs:
- deploys
env:
DOMAIN: apps.silver.devops.gov.bc.ca
NAME: nr-ticdi
runs-on: ubuntu-22.04
steps:
- name: Comment with links
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GHCR_TOKEN }}
with:
allow-repeats: false
message: |
DEV deployments have completed successfully!
[Backend](https://${{ env.NAME }}-${{ github.event.number }}-backend.${{ env.DOMAIN }}/) available
[Frontend](https://${{ env.NAME }}-${{ github.event.number }}-frontend.${{ env.DOMAIN }}/) available
# # Uncomment to view GitHub context object
# # https://docs.github.com/en/actions/learn-github-actions/contexts
# view-context:
# name: View GitHub Context
# runs-on: ubuntu-22.04
# steps:
# - name: Echo GitHub context
# uses: satackey/[email protected]
# with:
# script: |
# const github = require('@actions/github');
# console.log(JSON.stringify(github, null, 2));