Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: 자동배포 최종 main 머지 #627

Merged
merged 11 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ on:
env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: 42library.kr
CODE_DEPLOY_APPLICATION_NAME: newjiphyeonjeon
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: deploy
CODE_DEPLOY_APPLICATION_NAME: newjiphyeonjeonfrontend
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: deployfrontend
REACT_APP_API: ${{ secrets.REACT_APP_API }}
REACT_APP_WISH: ${{ secrets.REACT_APP_WISH }}
REACT_APP_E_BOOK_LIBRARY: ${{ secrets.REACT_APP_E_BOOK_LIBRARY }}
REACT_APP_SUGGESTION: ${{ secrets.REACT_APP_SUGGESTION }}
REACT_APP_GA_ID: ${{ secrets.REACT_APP_GA_ID }}
PORT: ${{ secrets.PORT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

jobs:
deploy:
Expand All @@ -36,13 +44,6 @@ jobs:
echo "REACT_APP_GA_ID=$REACT_APP_GA_ID" >> .env
echo "REACT_APP_SENTRY=$REACT_APP_SENTRY" >> .env
echo "PORT=$PORT" >> .env
env:
REACT_APP_API: ${{ secrets.REACT_APP_API }}
REACT_APP_WISH: ${{ secrets.REACT_APP_WISH }}
REACT_APP_E_BOOK_LIBRARY: ${{ secrets.REACT_APP_E_BOOK_LIBRARY }}
REACT_APP_SUGGESTION: ${{ secrets.REACT_APP_SUGGESTION }}
REACT_APP_GA_ID: ${{ secrets.REACT_APP_GA_ID }}
PORT: ${{ secrets.PORT }}

- name: Install Pnpm
uses: pnpm/action-setup@v2
Expand All @@ -52,18 +53,20 @@ jobs:
- name: Install Dependencies
run: pnpm install

- name : install chrome for prerender
- name : Install chrome for prerender
run: |
npx puppeteer browsers install chrome

- name: Build
run: pnpm build

- 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
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }}
aws-region: 'ap-northeast-2'


- name: Upload to AWS S3
run: |
Expand All @@ -72,10 +75,10 @@ jobs:
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \
--source .

- name: Deploy to AWS EC2 from S3
- 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 i
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip
2 changes: 1 addition & 1 deletion appspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ hooks:
ApplicationStart:
- location: scripts/start.sh
timeout: 120
runas: ubuntu
runas: ubuntu
5 changes: 2 additions & 3 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/sh

# TODO: add front file
sudo cp -r ~/frontend/build ~/backend/build


docker-compose -f ~/backend/docker-compose.yaml up -d --build
docker-compose -f ~/backend/docker-compose.yaml up -d --build
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const port = parseInt(env.PORT, 10);
// TODO: 추후 모든 책들의 id 추가. /info/*
const pagesForPrerender = ["/", "/info/1", "/info/42", "/info/1058"];
const pagesForPrerender = ["/"];

return {
/** @see https://vitejs.dev/plugins/ */
Expand Down
Loading