-
Notifications
You must be signed in to change notification settings - Fork 6
63 lines (58 loc) · 1.78 KB
/
prod-frontend-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
name: Frontend CD
on:
pull_request:
types: ["closed"]
branches: ["main"]
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: ./frontend
jobs:
build:
runs-on: ubuntu-latest
if: >
github.event.pull_request.merged == true &&
contains(join(github.event.pull_request.labels.*.name, ','), '💻Frontend')
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: frontend
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: npm install library
run: npm ci
# npm 테스트 진행
- name: Run test
run: npm run test
# AWS 로그인
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
# Docker 이미지 빌드
- name: Docker image build
run : |
docker build -t ${{ secrets.AWS_ECR }}/${{ secrets.YIGIL_API_FRONT_PROD }} . --platform=linux/amd64
- name: Docker image push
run : |
docker push ${{ secrets.AWS_ECR }}/${{ secrets.YIGIL_API_FRONT_PROD }}
# EC2 인스턴스 접속 및 애플리케이션 실행
- name: Application Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST_PROD }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
sh ./gitaction.sh