-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (104 loc) · 2.93 KB
/
react.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
96
97
98
99
100
101
102
103
104
name: React Project Workflow
on:
workflow_call:
inputs:
# Mandatory inputs
imageName:
required: TRUE
type: string
githubRef:
required: true
type: string
gitSha:
required: true
type: string
# Optional finetuning inputs
path:
required: False
type: string
default: .
dockerfile:
required: False
type: string
default: Dockerfile
skipReactCheck: # NOTE: Use with CAUTION!
required: False
type: boolean
default: false
nodeVersion:
required: False
type: string
default: 14
skipCodecov:
required: False
type: boolean
default: false
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
jobs:
react-check:
name: React Check
runs-on: ubuntu-latest
if: ${{ !inputs.skipReactCheck }}
steps:
- uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
with:
path: "**/node_modules"
key: v0-${{ hashFiles('${{ inputs.path }}/yarn.lock') }}
- name: Install Dependencies
run: |-
cd ${{ inputs.path }}
yarn install --frozen-lockfile
- name: Lint
run: |-
cd ${{ inputs.path }}
yarn lint
- name: Test
run: |-
cd ${{ inputs.path }}
yarn test
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
if: ${{ !inputs.skipCodecov }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ${{ inputs.path }}
fail_ci_if_error: true
name: codecov-umbrella
verbose: true
container:
image: node:${{ inputs.nodeVersion }}
publish-frontend:
name: Publish frontend
runs-on: ubuntu-latest
needs: react-check
if: |
always() &&
(needs.react-check.result == 'success' || needs.react-check.result == 'skipped')
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-publish-frontend
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build/Publish
uses: docker/build-push-action@v2
with:
context: ${{ inputs.path }}
file: ${{ inputs.path }}/${{ inputs.dockerfile }}
push: ${{ inputs.githubRef == 'master' }}
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/${{ inputs.imageName }}:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/${{ inputs.imageName }}:latest,pennlabs/${{ inputs.imageName }}:${{ inputs.gitSha }}