Skip to content

[ADD] aws 접근 플로우 추가 #1

[ADD] aws 접근 플로우 추가

[ADD] aws 접근 플로우 추가 #1

Workflow file for this run

name: DEV CD
on:
push:
branches: [ "develop" ]
jobs:
deploy-ci:
runs-on: ubuntu-22.04
env:
working-directory-spring: main
working-directory-nestjs: server
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies (npm 의존성 설치)
run: npm install
working-directory: ${{ env.working-directory-nestjs }}
- name: resources 폴더 내 application-secret.properties 파일 생성
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_SECRET }}" > src/main/resources/application-secret.properties
working-directory: ${{ env.working-directory-spring }}
- name: nestjs 폴더 내 .dev.env 파일 생성
run: |
echo "${{ secrets.APPLICATION_SECRET }}" > .dev.env
working-directory: ${{ env.working-directory-nestjs }}
- name: Build (Spring)
run: |
chmod +x gradlew
./gradlew clean build
working-directory: ${{ env.working-directory-spring }}
shell: bash
- name: Build (nestjs)
run: npm run build
working-directory: ${{ env.working-directory-nestjs }}
### 여기까지 CI와 거의 동일
- name: docker build 가능하도록 환경 설정
uses: docker/setup-buildx-action@v2
- name: docker hub에 로그인
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME }}
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN }}
- name: docker image 빌드 및 푸시 (Spring)
run: |
docker build --platform linux/amd64 -t makerscrew/main .
docker push makerscrew/main
working-directory: ${{ env.working-directory-spring }}
- name: docker image 빌드 및 푸시 (nestjs)
run: |
docker build --platform linux/amd64 -t makerscrew/server .
docker push makerscrew/server
working-directory: ${{ env.working-directory-nestjs }}
deploy-cd:
needs: deploy-ci
runs-on: ubuntu-22.04
steps:
- name: 도커 컨테이너 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_SERVER_IP }}
username: ${{ secrets.DEV_SERVER_USER }}
key: ${{ secrets.DEV_SERVER_KEY }}
script: |
cd ~
./deploy.sh