Skip to content

Merge pull request #512 from connection-2023/feature/#501 #423

Merge pull request #512 from connection-2023/feature/#501

Merge pull request #512 from connection-2023/feature/#501 #423

Workflow file for this run

name: Connection-CICD
on:
push:
branches: ['develop']
jobs:
cicd:
name: CI/CD
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup node.js
uses: actions/[email protected]
with:
node-version: 18.x
cache: 'npm'
- name: Install Backend-Server
run: npm ci
- name: Compile Backend-Server
run: npm run build
- name: Setting .env
run: |
# .env 파일 생성
echo "NODE_PORT=${{ secrets.NODE_PORT }}" >> .env
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> .env
echo "SENS_URL=${{ secrets.SENS_URL }}" >> .env
echo "SENS_API_KEY=${{ secrets.SENS_API_KEY }}" >> .env
echo "NAVER_ACCESS_KEY=${{ secrets.NAVER_ACCESS_KEY }}" >> .env
echo "NAVER_SECRET_KEY=${{ secrets.NAVER_SECRET_KEY }}" >> .env
echo "PHONE_NUMBER=${{ secrets.PHONE_NUMBER }}" >> .env
echo "SMS_USAGE_LIMIT=${{ secrets.SMS_USAGE_LIMIT }}" >> .env
echo "REDIS_URL=${{ secrets.REDIS_URL }}" >> .env
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> .env
echo "REDIS_SMS_TTL=${{ secrets.REDIS_SMS_TTL }}" >> .env
echo "REDIS_CATEGORY_TTL=${{ secrets.REDIS_CATEGORY_TTL }}" >> .env
echo "SWAGGER_USER=${{ secrets.SWAGGER_USER }}" >> .env
echo "SWAGGER_PASSWORD=${{ secrets.SWAGGER_PASSWORD }}" >> .env
echo "JWT_TOKEN_SECRET_KEY=${{ secrets.JWT_TOKEN_SECRET_KEY }}" >> .env
echo "JWT_ACCESS_TOKEN_EXPIRES_IN=${{ secrets.JWT_ACCESS_TOKEN_EXPIRES_IN }}" >> .env
echo "JWT_REFRESH_TOKEN_EXPIRES_IN=${{ secrets.JWT_REFRESH_TOKEN_EXPIRES_IN }}" >> .env
echo "JWT_REFRESH_TOKEN_TTL=${{ secrets.JWT_REFRESH_TOKEN_TTL }}" >> .env
echo "KAKAO_GET_USER_URI=${{ secrets.KAKAO_GET_USER_URI }}" >> .env
echo "GOOGLE_GET_USER_URI=${{ secrets.GOOGLE_GET_USER_URI }}" >> .env
echo "NAVER_GET_USER_URI=${{ secrets.NAVER_GET_USER_URI }}" >> .env
echo "FRONT_END_URL=${{ secrets.FRONT_END_URL }}" >> .env
echo "AWS_S3_BUCKET_NAME=${{ secrets.AWS_S3_BUCKET_NAME }}" >> .env
echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> .env
echo "AWS_S3_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }}" >> .env
echo "AWS_S3_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }}" >> .env
echo "KFT_GET_TOKEN_URI=${{ secrets.KFT_GET_TOKEN_URI }}" >> .env
echo "KFT_CLIENT_ID=${{ secrets.KFT_CLIENT_ID }}" >> .env
echo "KFT_CLIENT_SECRET=${{ secrets.KFT_CLIENT_SECRET }}" >> .env
echo "KFT_SCOPE=${{ secrets.KFT_SCOPE }}" >> .env
echo "KFT_GRANT_TYPE=${{ secrets.KFT_GRANT_TYPE }}" >> .env
echo "TOSS_PAYMENTS_SECRET_KEY=${{ secrets.TOSS_PAYMENTS_SECRET_KEY }}" >> .env
echo "TOSS_PAYMENTS_URL=${{ secrets.TOSS_PAYMENTS_URL }}" >> .env
echo "COUPON_SECRET_KEY=${{ secrets.COUPON_SECRET_KEY }}" >> .env
echo "HEX_STRING=${{ secrets.HEX_STRING }}" >> .env
echo "SEARCH_SERVER_URL=${{ secrets.SEARCH_SERVER_URL }}" >> .env
echo "ES_USERNAME=${{ secrets.ES_USERNAME }}" >> .env
echo "ES_PASSWORD=${{ secrets.ES_PASSWORD }}" >> .env
echo "MONGODB_URL=${{ secrets.MONGODB_URL }}" >> .env
echo "DISCORD_WEBHOOK_URL=${{ secrets.DISCORD_WEBHOOK_URL }}" >> .env
echo "PASS_REFUNDABLE_DAYS_PERIOD=${{ secrets.PASS_REFUNDABLE_DAYS_PERIOD }}" >> .env
echo "CANCELLATION_ABSOLUTE_TIME=${{ secrets.CANCELLATION_ABSOLUTE_TIME }}" >> .env
echo "PAYMENT_TIME_OUT_SEC=${{ secrets.PAYMENT_TIME_OUT_SEC }}" >> .env
echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> .env
echo "FIREBASE_ADMIN_SDK_PROJECT_ID=${{ secrets.FIREBASE_ADMIN_SDK_PROJECT_ID }}" >> .env
echo "FIREBASE_ADMIN_SDK_PRIVATE_KEY=${{ secrets.FIREBASE_ADMIN_SDK_PRIVATE_KEY }}" >> .env
echo "FIREBASE_ADMIN_SDK_CLIENT_EMAIL=${{ secrets.FIREBASE_ADMIN_SDK_CLIENT_EMAIL }}" >> .env
cat .env
# "node_modules/*" "coverage/*" "src/*" "test/*" "README.md" "*.git*" "/common" "tsconfig.json" "tsconfig.build.json" "nest-cli.json" 파일 제외 후 레퍼지토리 압축
- name: Make a zip file
run: zip -r ./$GITHUB_SHA.zip . -x "node_modules/*" "coverage/*" "src/*" "test/*" "README.md" "*.git*" "common/*" "tsconfig.json" "tsconfig.build.json" "nest-cli.json"
shell: bash
# AWS 자격 증명 수행
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
# zip 파일 S3 업로드
- name: Upload to S3
run: aws s3 cp --region ${{ secrets.AWS_REGION }} ./$GITHUB_SHA.zip s3://${{secrets.S3_BUCKET_NAME}}/${{secrets.PROJECT_NAME}}/$GITHUB_SHA.zip
# 코드 배포
- name: Code Deploy
run: aws deploy create-deployment
--application-name ${{secrets.AWS_CODEDEPLOY_APPLICATION_NAME}}
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name ${{secrets.AWS_CODEDEPLOY_DEPLOYMENT_GROUP_NAME}}
--s3-location bucket=${{secrets.S3_BUCKET_NAME}},bundleType=zip,key=${{secrets.PROJECT_NAME}}/$GITHUB_SHA.zip