update version2 #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 이 워크플로우는 Node의 의존성을 깔끔하게 설치하고, 캐시하여 복원하며, 소스 코드를 빌드하고 다양한 Node 버전에서 테스트를 실행합니다. | |
# 자세한 정보는 다음을 참조하세요: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: deploy | |
# main 브랜치에 push 혹은 pull request가 있을 때 워크플로우를 실행 | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# 워크플로우가 실행될 운영체제 지정 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
# 지원되는 Node.js 릴리스 일정에 대해서는 https://nodejs.org/en/about/releases/를 참조하세요. | |
# 워크플로우의 실행 단계 | |
steps: | |
# 소스 코드 체크아웃 | |
- name: Checkout source code. | |
uses: actions/checkout@v2 | |
# 사용할 Node.js 버전 설정 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# 의존성 설치 | |
- name: Install dependencies | |
run: npm install | |
# .env 파일 생성 | |
- name: create env file | |
working-directory: ./ | |
run: | | |
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .env | |
echo "DB_USER=${{ secrets.DB_USER }}" >> .env | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env | |
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .env | |
# 파일 및 폴더를 압축하여 server.zip으로 저장 | |
- name: zip distributions | |
run: zip -r server.zip . | |
# AWS 인증 정보 설정 | |
- name: AWS configure credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
# S3로 압축 파일 업로드 | |
- name: upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./server.zip s3://${{secrets.BUCKET_NAME}}/public/ | |
# AWS CodeDeploy를 사용하여 배포 | |
- name: deploy with AWS codeDeploy | |
run: aws deploy create-deployment | |
--application-name ${{secrets.CODEDEPLOY_APP_NAME}} | |
--deployment-config-name CodeDeployDefault.OneAtATime | |
--deployment-group-name ${{secrets.CODEDEPLOY_DG_NAME}} | |
--s3-location bucket=${{secrets.BUCKET_NAME}},bundleType=zip,key=public/server.zip |