From d60a02ca28c489a99a19dd0c031a3c835ea300e3 Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Mon, 1 Jan 2024 21:15:59 +0900 Subject: [PATCH 1/8] =?UTF-8?q?chore:=20pull-request=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/setup/action.yml | 13 +++++++++ .github/workflows/build-test.yml | 43 ---------------------------- .github/workflows/pull-request.yml | 46 ++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 43 deletions(-) create mode 100644 .github/actions/setup/action.yml delete mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..5fcd9e6 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,13 @@ +name: Setup +description: 'Node.js와 Yarn 패키지를 설치합니다.' +runs: + using: 'composite' + steps: + - name: Node.js 설정 + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Yarn 패키지 설치 + run: yarn + shell: bash diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml deleted file mode 100644 index 812b8cf..0000000 --- a/.github/workflows/build-test.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Build Test - -on: - pull_request: - branches: ['main'] - -jobs: - build-react: - 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 web build - build-express: - 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 - build-api-docs: - 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 api-docs build diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..cb1b66e --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,46 @@ +name: Build & Test + +on: + pull_request: + branches: ['main'] + +jobs: + react: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Node.js 및 Yarn 설치 + uses: ./.github/actions/setup + + - name: React 앱 빌드 + run: yarn web build + express: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Node.js 및 Yarn 설치 + uses: ./.github/actions/setup + + - name: env 파일 생성 + run: | + echo "${{ secrets.EXPRESS_ENV_FILE }}" >> .env + mv .env packages/slack/.env + cat packages/slack/.env + + - name: Express 앱 빌드 + run: yarn slack build + + - name: Express 앱 테스트 코드 실행 + run: yarn slack test + api-docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Node.js 및 Yarn 설치 + uses: ./.github/actions/setup + + - name: API 문서 빌드 + run: yarn api-docs build From adbd9809e890b8bab2ac686864e8ec2ead61b7fa Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Mon, 1 Jan 2024 21:20:35 +0900 Subject: [PATCH 2/8] =?UTF-8?q?chore:=20express,=20react=20deploy=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/express-deploy.yml | 55 +++++++--------------------- .github/workflows/pull-request.yml | 2 +- .github/workflows/react-deploy.yml | 19 +++++----- 3 files changed, 23 insertions(+), 53 deletions(-) diff --git a/.github/workflows/express-deploy.yml b/.github/workflows/express-deploy.yml index ea2a833..e73e438 100644 --- a/.github/workflows/express-deploy.yml +++ b/.github/workflows/express-deploy.yml @@ -2,7 +2,7 @@ name: Express CI/CD on: push: - branches: ['main'] + branches: ['refactor/228-github-actions'] jobs: build: @@ -10,66 +10,37 @@ jobs: 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 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index cb1b66e..724721a 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -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 diff --git a/.github/workflows/react-deploy.yml b/.github/workflows/react-deploy.yml index 0d707eb..4f76e94 100644 --- a/.github/workflows/react-deploy.yml +++ b/.github/workflows/react-deploy.yml @@ -2,7 +2,7 @@ name: React App CI/CD on: push: - branches: ['main'] + branches: ['refactor/228-github-actions'] jobs: build: @@ -10,12 +10,10 @@ jobs: 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 @@ -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: @@ -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 }} From 2ae4f4ddbb2fd8d52bca1caa89155292b0a00d3c Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Mon, 1 Jan 2024 21:24:58 +0900 Subject: [PATCH 3/8] =?UTF-8?q?chore:=20production-deploy=EB=A1=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=ED=86=B5=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...press-deploy.yml => production-deploy.yml} | 46 +++++++++++++++++- .github/workflows/react-deploy.yml | 48 ------------------- 2 files changed, 44 insertions(+), 50 deletions(-) rename .github/workflows/{express-deploy.yml => production-deploy.yml} (51%) delete mode 100644 .github/workflows/react-deploy.yml diff --git a/.github/workflows/express-deploy.yml b/.github/workflows/production-deploy.yml similarity index 51% rename from .github/workflows/express-deploy.yml rename to .github/workflows/production-deploy.yml index e73e438..4c5182a 100644 --- a/.github/workflows/express-deploy.yml +++ b/.github/workflows/production-deploy.yml @@ -1,11 +1,53 @@ -name: Express CI/CD +name: Production CD on: push: branches: ['refactor/228-github-actions'] jobs: - build: + react: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Node.js 및 Yarn 설치 + uses: ./.github/actions/setup + + - name: .env 파일 생성 + run: | + echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> .env + echo "VITE_API_ENDPOINT=${{ secrets.VITE_API_ENDPOINT }}" >> .env + echo "VITE_SLACK_API_ENDPOINT=${{ secrets.VITE_SLACK_API_ENDPOINT }}" >> .env + echo "VITE_CHANNEL_ID=${{ secrets.VITE_CHANNEL_ID }}" >> .env + echo "VITE_SLACK_ID_DESCRIPTION=${{ secrets.VITE_SLACK_ID_DESCRIPTION }}" >> .env + + mv .env packages/web/.env + cat packages/web/.env + + - name: React 앱 빌드 + run: yarn web build + + - name: 빌드된 파일 S3에 배포 + uses: awact/s3-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + SOURCE_DIR: './packages/web/dist' + AWS_REGION: 'ap-northeast-2' + AWS_S3_BUCKET: ${{ secrets.AWS_CLIENT_S3_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_SECRET_KEY }} + + - name: CloudFront 캐시 무효화 + uses: chetan/invalidate-cloudfront-action@v2 + env: + DISTRIBUTION: ${{ secrets.AWS_CLIENT_CLOUDFRONT_ID }} + PATHS: '/*' + AWS_REGION: 'ap-northeast-2' + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_SECRET_KEY }} + + express: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/react-deploy.yml b/.github/workflows/react-deploy.yml deleted file mode 100644 index 4f76e94..0000000 --- a/.github/workflows/react-deploy.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: React App CI/CD - -on: - push: - branches: ['refactor/228-github-actions'] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Node.js 및 Yarn 설치 - uses: ./.github/actions/setup - - - name: .env 파일 생성 - run: | - echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> .env - echo "VITE_API_ENDPOINT=${{ secrets.VITE_API_ENDPOINT }}" >> .env - echo "VITE_SLACK_API_ENDPOINT=${{ secrets.VITE_SLACK_API_ENDPOINT }}" >> .env - echo "VITE_CHANNEL_ID=${{ secrets.VITE_CHANNEL_ID }}" >> .env - echo "VITE_SLACK_ID_DESCRIPTION=${{ secrets.VITE_SLACK_ID_DESCRIPTION }}" >> .env - - mv .env packages/web/.env - cat packages/web/.env - - - name: React 앱 빌드 - run: yarn web build - - - name: 빌드된 파일 S3에 배포 - uses: awact/s3-action@master - with: - args: --acl public-read --follow-symlinks --delete - env: - SOURCE_DIR: './packages/web/dist' - AWS_REGION: 'ap-northeast-2' - AWS_S3_BUCKET: ${{ secrets.AWS_CLIENT_S3_BUCKET }} - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_SECRET_KEY }} - - - name: CloudFront 캐시 무효화 - uses: chetan/invalidate-cloudfront-action@v2 - env: - DISTRIBUTION: ${{ secrets.AWS_CLIENT_CLOUDFRONT_ID }} - PATHS: '/*' - AWS_REGION: 'ap-northeast-2' - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_SECRET_KEY }} From d6dfb635984efd9c6af0ffa5e1da879e86a0cde9 Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Mon, 1 Jan 2024 21:30:07 +0900 Subject: [PATCH 4/8] =?UTF-8?q?chore:=20=ED=8C=8C=EC=9D=BC=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/{production-deploy.yml => deploy-production.yml} | 2 +- .github/workflows/pull-request.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename .github/workflows/{production-deploy.yml => deploy-production.yml} (98%) diff --git a/.github/workflows/production-deploy.yml b/.github/workflows/deploy-production.yml similarity index 98% rename from .github/workflows/production-deploy.yml rename to .github/workflows/deploy-production.yml index 4c5182a..755acab 100644 --- a/.github/workflows/production-deploy.yml +++ b/.github/workflows/deploy-production.yml @@ -2,7 +2,7 @@ name: Production CD on: push: - branches: ['refactor/228-github-actions'] + branches: ['main'] jobs: react: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 724721a..275fb64 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -15,6 +15,7 @@ jobs: - name: React 앱 빌드 run: yarn web build + express: runs-on: ubuntu-latest steps: @@ -34,6 +35,7 @@ jobs: - name: Express 앱 테스트 코드 실행 run: yarn slack test + api-docs: runs-on: ubuntu-latest steps: From 64afee5647b5a08ea803b01a0f6f5b3401df8c8a Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Mon, 1 Jan 2024 23:47:30 +0900 Subject: [PATCH 5/8] =?UTF-8?q?chore:=20swagger-cli=20=EB=B9=8C=EB=93=9C?= =?UTF-8?q?=EC=97=90=20validate=20=EC=BB=A4=EB=A7=A8=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/api-docs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api-docs/package.json b/packages/api-docs/package.json index 07e4c5f..bd21bab 100644 --- a/packages/api-docs/package.json +++ b/packages/api-docs/package.json @@ -2,7 +2,7 @@ "name": "api-docs", "packageManager": "yarn@3.6.3", "scripts": { - "build": "tsc && swagger-cli bundle ./src/swagger/index.yaml --outfile dist/swagger.yaml --type yaml", + "build": "tsc && swagger-cli bundle ./src/swagger/index.yaml --outfile dist/swagger.yaml --type yaml && swagger-cli validate ./dist/swagger.yaml", "start": "swagger-cli bundle ./src/swagger/index.yaml --outfile dist/swagger.yaml --type yaml && ts-node src/app.ts" }, "devDependencies": { From 8d24af44c866bef3a31822a223d534f3563f86f2 Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Mon, 1 Jan 2024 23:58:35 +0900 Subject: [PATCH 6/8] =?UTF-8?q?chore:=20react=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=EC=97=90=20api-docs=20=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pull-request.yml | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 275fb64..7e877a0 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -5,7 +5,7 @@ on: branches: ['main'] jobs: - react: + api-docs-and-react: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -13,6 +13,12 @@ jobs: - name: Node.js 및 Yarn 설치 uses: ./.github/actions/setup + - name: API 문서 빌드 + run: yarn api-docs build + + - name: API 문서로부터 타입 및 함수 자동 생성 + run: yarn web orval-generate + - name: React 앱 빌드 run: yarn web build @@ -35,14 +41,3 @@ jobs: - name: Express 앱 테스트 코드 실행 run: yarn slack test - - api-docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Node.js 및 Yarn 설치 - uses: ./.github/actions/setup - - - name: API 문서 빌드 - run: yarn api-docs build From 244c0b44e44ba8e56fc8e56e259492c8f85af858 Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Tue, 2 Jan 2024 00:00:16 +0900 Subject: [PATCH 7/8] =?UTF-8?q?chore:=20yarn=20web=20orval=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 7e877a0..06b2e90 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -17,7 +17,7 @@ jobs: run: yarn api-docs build - name: API 문서로부터 타입 및 함수 자동 생성 - run: yarn web orval-generate + run: yarn web orval - name: React 앱 빌드 run: yarn web build From f253099835a366ba0c05a008a14ec0b52577d828 Mon Sep 17 00:00:00 2001 From: bbearcookie Date: Tue, 2 Jan 2024 18:26:03 +0900 Subject: [PATCH 8/8] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=EB=8A=94=20=EB=B9=8C=EB=93=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/slack/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/slack/tsconfig.json b/packages/slack/tsconfig.json index 797f0ab..125e9d4 100644 --- a/packages/slack/tsconfig.json +++ b/packages/slack/tsconfig.json @@ -33,5 +33,5 @@ "noFallthroughCasesInSwitch": true }, "include": ["src", "./src/**/*.ts"], - "exclude": ["node_modules", "dist"] + "exclude": ["node_modules", "dist", "src/**/*.test.ts"] }