ci: 배포 깃허브 액션 이름 EC2에서 LightSail로 변경 (#832) #111
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
name: Deploy to Amazon LightSail | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
# 본인이 설정한 값을 여기서 채워넣습니다. | |
# 리전, 버킷 이름, CodeDeploy 앱 이름, CodeDeploy 배포 그룹 이름 | |
env: | |
AWS_REGION: ap-northeast-2 | |
S3_BUCKET_NAME: 42library.kr | |
CODE_DEPLOY_APPLICATION_NAME: newjiphyeonjeon | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: deploy | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
# (1) 기본 체크아웃 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: setup pnpm | |
run: | | |
corepack enable | |
corepack prepare pnpm@latest-8 --activate | |
pnpm config set store-dir .pnpm-store | |
- name: install dependencies | |
working-directory: backend | |
run: pnpm install | |
# TODO(@scarf005): #594 | |
# - name: build backend | |
# working-directory: backend | |
# run: pnpm build | |
- name: create .env file | |
run: | | |
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }} | |
MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }} | |
MYSQL_USER=${{ secrets.MYSQL_USER }} | |
MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} | |
BACKUP_USER=${{ secrets.BACKUP_USER}} | |
BACKUP_PASSWORD=${{ secrets.BACKUP_PASSWORD }} | |
ADMIN_SLACK_ID=${{ secrets.ADMIN_SLACK_ID }} | |
DB_SCHEMA=${{ secrets.DB_SCHEMA }} | |
MODE=${{ secrets.MODE }} | |
NODE_ENV=${{ secrets.NODE_ENV }} | |
CLIENT_ID=${{ secrets.CLIENT_ID }} | |
CLIENT_SECRET=${{ secrets.CLIENT_SECRET }} | |
REDIRECT_URL=${{ secrets.REDIRECT_URL }} | |
CLIENT_URL=${{ secrets.CLIENT_URL }} | |
BOT_USER_OAUTH_ACCESS_TOKEN=${{ secrets.BOT_USER_OAUTH_ACCESS_TOKEN }} | |
JWT_SECRET=${{ secrets.JWT_SECRET }} | |
NAVER_BOOK_SEARCH_CLIENT_ID=${{ secrets.NAVER_BOOK_SEARCH_CLIENT_ID }} | |
NATION_LIBRARY_KEY=${{ secrets.NATION_LIBRARY_KEY }} | |
NAVER_BOOK_SEARCH_SECRET=${{ secrets.NAVER_BOOK_SEARCH_SECRET }}" > .env | |
- name: Configure AWS 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 | |
- name: Upload to AWS S3 | |
run: | | |
aws deploy push \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \ | |
--source . | |
- name: Deploy to AWS LightSail from S3 | |
run: | | |
aws deploy create-deployment \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ | |
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip |