-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (151 loc) · 4.39 KB
/
github.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
151
name: github
on: [push, pull_request]
jobs:
install:
name: install
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: Install dependencies
run: |
if [ -e package-lock.json ]; then
npm ci
else
npm i
fi
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: 'node_modules/'
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
build:
name: build
runs-on: ${{matrix.os}}
needs:
- install
strategy:
matrix:
os: [ ubuntu-latest ]
steps:
- name: Checkout
uses: actions/[email protected]
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Get cached file
uses: actions/cache@v3
id: cache-npm
env:
cache-name: cache-node-modules
with:
path: 'node_modules/'
key: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Check directory
run: echo $(ls .)
- name: Linting
run: npm run lint
- name: Remove previous build
run: npm run prebuild
- name: Build frontend files
run: npm run build:frontend
- name: Archive frontend
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: frontend
path: .next/
retention-days: 5
- name: Build backend files
run: npm run build:backend
- name: Archive backend files
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: backend
path: dist/
retention-days: 5
release:
name: release
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- build
steps:
- name: Checkout
uses: actions/[email protected]
- name: Get cached node_modules
uses: actions/cache@v3
id: cache-npm
env:
cache-name: cache-node-modules
with:
path: 'node_modules/'
key: ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Get Backend files
uses: actions/download-artifact@v3
with:
name: backend
path: dist/
- name: Get Frontend files
uses: actions/download-artifact@v3
with:
name: frontend
path: .next/
- name: Release new version
uses: cycjimmy/semantic-release-action@v3
with:
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'main',
'next',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
extends: |
@semantic-release/apm-config
id: release_info
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_FOR_GITHUB }}
- name: Generate deployment package
uses: montudor/action-zip@v1
with:
args: zip -qq -r deploy.zip .
- name: Get Release files
if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v3
with:
name: deploy
path: deploy.zip
retention-days: 5
- name: Deploy to AWS Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v20
with:
use_existing_version_if_available: true
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: kaifstore
environment_name: Kaifstore-env-1
version_label: v-kaifstore-${{ steps.release_info.outputs.new_release_version }}
region: eu-central-1
deployment_package: deploy.zip
version_description: ${{ steps.semantic.outputs.new_release_notes }}