-
Notifications
You must be signed in to change notification settings - Fork 11
62 lines (51 loc) · 1.54 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
name: Next.js Template CD
on:
push:
branches:
- master
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
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 }}
- 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
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}-${{ env.ENV_NAME }}
SOURCE_DIR: './out/'
- name: Invalidate CloudFront
if: github.ref == 'refs/heads/master'
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.DISTRIBUTION_ID }}
PATHS: '/*'