generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 39
/
action.yml
85 lines (78 loc) · 2.77 KB
/
action.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
# action.yml
name: "Build Frontend"
description: "Build react website"
inputs:
env-name:
required: true
appinsights-staging-key:
description: Instrumentation key for staging environment
required: true
appinsights-prod-key:
description: Instrumentation key for production environment
required: true
version:
description: "Version tag"
required: true
GITHUB_TOKEN:
description: Github provided token
required: false
default: ""
SONAR_TOKEN:
description: Token to communicate with Sonarcloud
required: false
default: ""
runs:
using: "composite"
steps:
- name: Use Node.js ${{ matrix.node-version }} with yarn
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version: "18.14.2"
- run: yarn install
working-directory: frontend-react
shell: bash
- name: Build release for production branch (conditional check)
if: inputs.env-name == 'prod'
working-directory: frontend-react
run: |
echo "" >> .env.production
echo "REACT_APP_APPINSIGHTS_KEY=${{ inputs.appinsights-prod-key }}" >> .env.production
yarn test:ci
yarn build:production
shell: bash
- name: Build release for non-production branch (conditional check)
if: inputs.env-name != 'prod'
working-directory: frontend-react
run: |
ENV=${{ inputs.env-name }}
if [[ $ENV != demo* && $ENV != "test" ]]; then ENV="staging"; fi
echo "" >> .env.$ENV
echo "REACT_APP_APPINSIGHTS_KEY=${{ inputs.appinsights-staging-key }}" >> .env.$ENV
yarn lint
yarn test:ci
yarn build:$ENV
shell: bash
- name: SonarCloud Scan
if: inputs.GITHUB_TOKEN != '' && inputs.SONAR_TOKEN != ''
uses: sonarsource/sonarcloud-github-action@db501078e936e4b4c8773d1bb949ba9ddb7b6b6a
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ inputs.SONAR_TOKEN }}
with:
args: >
-Dsonar.cpd.exclusions=frontend-react/**/*.test.*
-Dsonar.javascript.lcov.reportPaths=frontend-react/coverage/lcov.info
-Dsonar.coverage.exclusions=frontend-react/**/__mocks__/**,frontend-react/**/mocks/**,frontend-react/**/*.test.*
-Dsonar.sources=frontend-react/src
-Dsonar.projectKey=CDCgov_prime-data-hub
-Dsonar.organization=cdcgov
- name: Tar frontend files
shell: bash
working-directory: frontend-react
run: tar -czf static-website-react.tar.gz build
- name: Upload frontend artifact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce
with:
name: static-website-react-${{ inputs.version }}
path: frontend-react/static-website-react.tar.gz
retention-days: 1