-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. .github/workflows/* => github action 2. scripts/* => EC2 shell script (Code Deploy hook) 3. appSpec.yml => CodeDeploy 동작 정의 4. ecosystem.config.js => pm2 configure 파일
- Loading branch information
Showing
13 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: deploy to S3 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
S3_BUCKET_NAME: chagok-bucket | ||
CODE_DEPLOY_APPLICATION_NAME: chagok-code-deploy | ||
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: chagok | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "npm" | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
# 프로젝트를 빌드한다. | ||
- name: Build next app | ||
run: npm run build | ||
|
||
- name: Make zip file | ||
run: zip -qq -r ./chagok.zip . -x "node_modules/*" | ||
# -x "node_modules/*" | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
# Make zip file 단계에서 압축된 빌드 파일을 S3 버킷에 업로드하는 단계이다. | ||
- name: Upload to S3 | ||
run: aws s3 cp --region ap-northeast-2 ./chagok.zip s3://$S3_BUCKET_NAME/chagok.zip | ||
|
||
# S3에 업로드 된 빌드 파일을 이용해 CodeDeploy가 정의된 동작을 하도록 트리거 | ||
- name: Code Deploy | ||
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,bundleType=zip,key=chagok.zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run build --if-present | ||
- run: npm test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run test | ||
npx lint-staged |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.yml | ||
*.sh |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: 0.0 | ||
os: linux | ||
|
||
files: | ||
- source: / | ||
destination: /home/ubuntu/chagok | ||
overwrite: yes | ||
permissions: | ||
- object: /home/ubuntu/chagok | ||
owner: ubuntu | ||
group: ubuntu | ||
mode: 755 | ||
hooks: | ||
AfterInstall: | ||
- location: scripts/after-install.sh | ||
timeout: 120 | ||
runas: root | ||
ApplicationStart: | ||
- location: scripts/app-start.sh | ||
timeout: 300 | ||
runas: root |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
apps: [ | ||
{ | ||
name: "project", | ||
script: "npm", | ||
args: "run start", | ||
instances: 2, | ||
autorestart: true, | ||
watch: false, | ||
env: { | ||
PORT: 3000, | ||
NODE_ENV: "development", | ||
}, | ||
env_production: { | ||
PORT: 3000, | ||
NODE_ENV: "production", | ||
}, | ||
output: "./logs/console.log", | ||
error: "./logs/consoleError.log", | ||
}, | ||
], | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
echo "> after install" | ||
|
||
cd /home/ubuntu/chagok | ||
sudo rm -r node_modules | ||
npm install | ||
npm run build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
echo "app start ;)" |
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
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