-
Notifications
You must be signed in to change notification settings - Fork 92
87 lines (73 loc) · 2.32 KB
/
cd.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
name: React Template CD
on:
push:
branches:
- master
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.6.2]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Get branch name
id: vars
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
- name: Set env.ENV_NAME
run: |
if [[ ${{steps.vars.outputs.short_ref}} == 'master' ]]; then
echo "ENV_NAME=prod" >> "$GITHUB_ENV"
else
echo "ENV_NAME=dev" >> "$GITHUB_ENV"
fi
- name: Install dependencies
run: yarn
- name: Build
run: yarn build:${{ env.ENV_NAME }}
- name: Lint
run: yarn lint
- name: Deploy to S3
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --exclude 'tests/*'
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}-${{ env.ENV_NAME }}
SOURCE_DIR: './build/'
- name: Invalidate CloudFront
if: github.ref == 'refs/heads/master'
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.DISTRIBUTION_ID }}
PATHS: '/*'
- name: Create badges
run: yarn run test:badges
- name: Commit badges
uses: EndBug/add-and-commit@v7
with:
author_name: Gitflow
author_email: [email protected]
message: 'Update badges'
add: 'badges/'
push: false
- name: Pushing to a protected branch
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.PUSH_TO_PROTECTED_BRANCH }}
branch: ${{ steps.vars.outputs.short_ref }}
unprotect_reviews: true
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}