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/CD] 배포 환경 세팅 및 개발 환경세팅 추가 #2

Merged
merged 10 commits into from
Jul 3, 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
21 changes: 21 additions & 0 deletions .ebextensions/00-makeFiles.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
files:
"/etc/nginx/conf.d/vueapp.conf":
mode: "000755"
owner: root
group: root
content: |
server {
listen 80;
server_name _;

location / {
root /var/app/current/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
4 changes: 1 addition & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
> 변경 사항 및 관련 이슈에 대해 간단하게 작성해주세요. 어떻게보다 무엇을 왜 수정했는지 설명해주세요.
- 이곳에 변경 사항 및 관련 이슈에 대해 간단하게 작성해주세요.(**목록형식으로 작성해주세요.**)

## 📍 변경 사항
- 이곳에 변경 사항 및
| Resolves | #(Isuue Number) |
| Resolves | #(Isuue Number) |

## 📍 PR 유형
어떤 변경 사항이 있나요?
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/codereview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 코드리뷰

permissions:
contents: read
pull-requests: write

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: ChatGPT 코드리뷰
uses: anc95/ChatGPT-CodeReview@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
LANGUAGE: Korean
PROMPT: 다음 코드 차이점에 혼동이나 불규칙이 있는지 확인해주세요(코드리뷰)
179 changes: 89 additions & 90 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,90 +1,89 @@
#name: MarketNawaFE
#
#on:
# push:
# branches:
# - main
# - develop
#
#jobs:
# deploy:
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
#
# - name: Setup Node.js
# uses: actions/setup-node@v2
# with:
# node-version: '20.x'
#
# - name: Install dependencies
# run: npm ci
#
# - name: Build project
# run: npm run build
#
# - name: Install AWS CLI
# run: |
# curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
# unzip awscliv2.zip
# sudo ./aws/install --update
#
# - 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
#
# - name: Generate deployment package
# run: |
# mkdir -p .ebextensions
# cat <<EOF > .ebextensions/00-makeFiles.config
# files:
# "/etc/nginx/conf.d/vueapp.conf":
# mode: "000755"
# owner: root
# group: root
# content: |
# server {
# listen 80;
# server_name _;
#
# location / {
# proxy_pass http://127.0.0.1:8080;
# proxy_http_version 1.1;
# proxy_set_header Upgrade \$http_upgrade;
# proxy_set_header Connection 'upgrade';
# proxy_set_header Host \$host;
# proxy_cache_bypass \$http_upgrade;
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root /usr/share/nginx/html;
# }
# }
# EOF
# cat <<EOF > Procfile
# web: node server.js
# EOF
# mkdir -p deploy
# cp -r dist deploy/
# cp package.json deploy/
# cp server.js deploy/
# cp Procfile deploy/
# cp -r .ebextensions deploy/
# cd deploy && zip -r deploy.zip .
#
# - name: Beanstalk Deploy
# uses: einaregilsson/beanstalk-deploy@v22
# with:
# aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# application_name: MarketNawaFE
# environment_name: MarketNawaFE-env
# version_label: github-action-${{ github.sha }}
# region: ap-northeast-2
# deployment_package: deploy/deploy.zip
name: MarketNawaFE

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20.x'

- name: Install dependencies
run: npm ci

- name: Build project
run: npm run build

- name: Install AWS CLI
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install --update

- 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

- name: Generate deployment package
run: |
mkdir -p .ebextensions
cat <<EOF > .ebextensions/00-makeFiles.config
files:
"/etc/nginx/conf.d/vueapp.conf":
mode: "000755"
owner: root
group: root
content: |
server {
listen 80;
server_name _;

location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_cache_bypass \$http_upgrade;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
EOF
cat <<EOF > Procfile
web: node server.js
EOF
mkdir -p deploy
cp -r dist deploy/
cp package.json deploy/
cp server.js deploy/
cp Procfile deploy/
cp -r .ebextensions deploy/
cd deploy && zip -r deploy.zip .

- name: Beanstalk Deploy
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: MarketNawaFE
environment_name: MarketNawaFE-env
version_label: github-action-${{ github.sha }}
region: ap-northeast-2
deployment_package: deploy/deploy.zip
37 changes: 37 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR 리뷰 및 댓글 확인

on:
pull_request:
types: [opened, synchronize, reopened]
pull_request_review:
types: [submitted]
pull_request_review_comment:
types: [created]

jobs:
check-reviews-and-comments:
runs-on: ubuntu-latest

steps:
- name: 리포지토리 체크아웃
uses: actions/checkout@v2

- name: 풀 리퀘스트 리뷰 및 댓글 가져오기
id: get_reviews_and_comments
run: |
REVIEWS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews" | jq -r '.[].user.login' | tr '\n' ' ')
COMMENTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | jq -r '.[].user.login' | tr '\n' ' ')
ALL_USERS="$REVIEWS $COMMENTS"
echo "ALL_USERS=\"$ALL_USERS\"" >> $GITHUB_ENV

- name: 고유 사용자 확인
run: |
echo "ALL_USERS=$ALL_USERS"
UNIQUE_USERS=$(echo "$ALL_USERS" | tr ' ' '\n' | sort | uniq | wc -l)
echo "Unique Users Count: $UNIQUE_USERS"
if [ "$UNIQUE_USERS" -lt 2 ]; then
echo "고유 리뷰어 및 댓글 작성자가 충분하지 않습니다. 머지 전에 최소 2명의 고유 리뷰어 또는 댓글 작성자가 있어야 합니다."
exit 1
fi
env:
ALL_USERS: ${{ env.ALL_USERS }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주어진 코드는 PR 리뷰 및 댓글을 확인하여 충분한 리뷰어와 댓글 작성자가 있는지 검사하는 GitHub Actions workflow입니다. 코드에 혼동이나 불규칙은 보이지 않습니다. 다만 주의할 점은 curl과 같은 외부 명령어를 사용할 때 인증 토큰이나 중요 정보가 노출되지 않도록 안전하게 관리해야 합니다.

30 changes: 30 additions & 0 deletions .platform/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
mkdir -p .platform
cat <<EOF > .platform/nginx.config
files:
"/etc/nginx/conf.d/vueapp.conf":
mode: "000644"
owner: root
group: root
content: |
server {
listen 80;
server_name _;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location / {
root /var/app/current/dist;
index index.html;
try_files \$uri \$uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
container_commands:
01_reload_nginx:
command: "nginx -s reload"
EOF
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.7.2/font/bootstrap-icons.min.css">
<title>Vite App</title>
<title>마켓나와</title>
</head>
<body>
<div id="app"></div>
Expand Down
Binary file modified public/favicon.ico
Binary file not shown.
14 changes: 14 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const express = require('express');
const path = require('path');
const app = express();
const PORT = process.env.PORT || 8080;

app.use(express.static(path.join(__dirname, 'dist')));

app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
});

app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
35 changes: 23 additions & 12 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { fileURLToPath, URL } from 'node:url'
import { fileURLToPath, URL } from 'node:url';
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
return {
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: 5173,
},
build: {
outDir: 'dist',
},
define: {
'process.env': {
VITE_APP_BACKEND_URL: env.VITE_APP_BACKEND_URL
}
}
}
})
});
Loading