Skip to content

Commit

Permalink
chore: express, react deploy 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
bbearcookie committed Jan 1, 2024
1 parent d60a02c commit adbd980
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 53 deletions.
55 changes: 13 additions & 42 deletions .github/workflows/express-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,45 @@ name: Express CI/CD

on:
push:
branches: ['main']
branches: ['refactor/228-github-actions']

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x

- run: yarn
- run: yarn slack build
- name: Node.js 및 Yarn 설치
uses: ./.github/actions/setup

- name: Setting .env
- name: .env 파일 생성
run: |
echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> .env
echo "PORT=${{ secrets.PORT }}" >> .env
echo "LOCAL_API_ENDPOINT=${{ secrets.LOCAL_API_ENDPOINT }}" >> .env
echo "DEPLOY_API_ENDPOINT=${{ secrets.DEPLOY_API_ENDPOINT }}" >> .env
echo "LOCAL_CLIENT_ENDPOINT=${{ secrets.LOCAL_CLIENT_ENDPOINT }}" >> .env
echo "DEPLOY_CLIENT_ENDPOINT=${{ secrets.DEPLOY_CLIENT_ENDPOINT }}" >> .env
echo "DEPLOY_CLIENT_ENDPOINT_LEGACY=${{ secrets.DEPLOY_CLIENT_ENDPOINT_LEGACY }}" >> .env
echo "LOCAL_REDIS_ENDPOINT=${{ secrets.LOCAL_REDIS_ENDPOINT }}" >> .env
echo "DEPLOY_REDIS_ENDPOINT=${{ secrets.DEPLOY_REDIS_ENDPOINT }}" >> .env
echo "DEPLOY_REDIS_PASSWORD=${{ secrets.DEPLOY_REDIS_PASSWORD }}" >> .env
echo "SNS_API_ENDPOINT=${{ secrets.SNS_API_ENDPOINT }}" >> .env
echo "SLACK_API_ENDPOINT=${{ secrets.SLACK_API_ENDPOINT }}" >> .env
echo "SLACK_HOOK_ENDPOINT=${{ secrets.SLACK_HOOK_ENDPOINT }}" >> .env
echo "SLACK_BOT_TOKEN=${{ secrets.SLACK_BOT_TOKEN }}" >> .env
echo "SLACK_SIGNING_SECRET=${{ secrets.SLACK_SIGNING_SECRET }}" >> .env
echo "DB_DATABASE=${{ secrets.DB_DATABASE }}" >> .env
echo "LOCAL_DB_USERNAME=${{ secrets.LOCAL_DB_USERNAME }}" >> .env
echo "LOCAL_DB_PASSWORD=${{ secrets.LOCAL_DB_PASSWORD }}" >> .env
echo "DEPLOY_DB_HOST=${{ secrets.DEPLOY_DB_HOST }}" >> .env
echo "DEPLOY_DB_USERNAME=${{ secrets.DEPLOY_DB_USERNAME }}" >> .env
echo "DEPLOY_DB_PASSWORD=${{ secrets.DEPLOY_DB_PASSWORD }}" >> .env
echo "${{ secrets.EXPRESS_ENV_FILE }}" >> .env
mv .env packages/slack/.env
cat packages/slack/.env
- name: Move appspec.yml
- name: Express 앱 빌드
run: yarn slack build

- name: appspec.yml 파일을 루트 디렉토리로 이동
run: |
mv packages/slack/appspec.yml appspec.yml
mv packages/slack/scripts scripts
- name: AWS configure credentials
- name: AWS Credentials 설정
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_BACKEND_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_BACKEND_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Compress Files
- name: 빌드 내용 및 배포 파일 압축
run: tar cvfz ./$GITHUB_SHA.gz packages/common packages/slack scripts appspec.yml package.json tsconfig.base.json yarn.lock .yarnrc.yml .yarn

- name: Upload to S3
- name: 압축 파일 S3 업로드
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.gz s3://${{secrets.AWS_BACKEND_S3_BUCKET}}/deployment/$GITHUB_SHA.gz

- name: Code Deploy
- name: CodeDeploy 배포
run: aws deploy create-deployment
--application-name ${{secrets.AWS_BACKEND_CODEDEPLOY_APPLICATION_NAME}}
--deployment-config-name CodeDeployDefault.AllAtOnce
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Node.js 및 Yarn 설치
uses: ./.github/actions/setup

- name: env 파일 생성
- name: .env 파일 생성
run: |
echo "${{ secrets.EXPRESS_ENV_FILE }}" >> .env
mv .env packages/slack/.env
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/react-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@ name: React App CI/CD

on:
push:
branches: ['main']
branches: ['refactor/228-github-actions']

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Node.js 및 Yarn 설치
uses: ./.github/actions/setup

- name: Setting .env
- name: .env 파일 생성
run: |
echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> .env
echo "VITE_API_ENDPOINT=${{ secrets.VITE_API_ENDPOINT }}" >> .env
Expand All @@ -26,10 +24,11 @@ jobs:
mv .env packages/web/.env
cat packages/web/.env
- run: yarn
- run: yarn web build
- name: React 앱 빌드
run: yarn web build

- uses: awact/s3-action@master
- name: 빌드된 파일 S3에 배포
uses: awact/s3-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
Expand All @@ -39,7 +38,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_SECRET_KEY }}

- name: Invalidate CloudFront
- name: CloudFront 캐시 무효화
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CLIENT_CLOUDFRONT_ID }}
Expand Down

0 comments on commit adbd980

Please sign in to comment.