Skip to content

Commit

Permalink
feat: set up CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
hookor authored and cuconveniencestore committed May 29, 2024
1 parent e0ee053 commit d434a78
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 14 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: DDocker to AWS EC2

on:
push:
branches:
- main

jobs:
deploy:
name: Build and Delpoy React
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.15.0]
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 8.10.5
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Get PNPM cache directory
id: pnpm-cache-dir
run: |
echo "::set-output name=dir::$(pnpm config get store-dir)"
- uses: actions/cache@v3
id: pnpm-cache
with:
path: ${{ steps.pnpm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: pnpm install

- name: Project running check
run: pnpm prod & npx wait-on tcp:127.0.0.1:${{ secrets.PORT}} -t 5s
env:
PORT: ${{ secrets.PORT }}
DB_HOST: ${{ secrets.DB_HOST }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_SCHEMA: ${{ secrets.DB_SCHEMA }}
ORIGIN: ${{ secrets.ORIGIN }}
CREDENTIALS: ${{ secrets.CREDENTIALS }}
ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
GOOGLE_REDIRECT_URI: ${{ secrets.GOOGLE_REDIRECT_URI }}
GOOGLE_UNLINK_URI: ${{ secrets.GOOGLE_UNLINK_URI }}
GOOGLE_TOKEN_URL: ${{ secrets.GOOGLE_TOKEN_URL }}
GOOGLE_USERINFO_URL: ${{ secrets.GOOGLE_USERINFO_URL }}
KAKAO_CLIENT_ID: ${{ secrets.KAKAO_CLIENT_ID }}
KAKAO_REDIRECT_URI: ${{ secrets.KAKAO_REDIRECT_URI }}
KAKAO_UNLINK_URI: ${{ secrets.KAKAO_UNLINK_URI }}
KAKAO_TOKEN_URL: ${{ secrets.KAKAO_TOKEN_URL }}
KAKAO_USERINFO_URL: ${{ secrets.KAKAO_USERINFO_URL }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
REDIS_URL: ${{ secrets.REDIS_URL }}

- name: SSH deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_SSH_HOST }}
username: ${{ secrets.AWS_SSH_USERNAME }}
password: ${{ secrets.AWS_SSH_PASSWORD }}
port: 22
script: |
sudo su
cd ~/DDocker_BE
git pull origin main
pnpm reload
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (process.env.NODE_ENV === undefined) {
}

const CREDENTIALS = (process.env.CREDENTIALS = true);
const ORIGIN = (process.env.ORIGIN = 'http://localhost:3000');
const ORIGIN = (process.env.ORIGIN = 'https://ddocker.kro.kr');

const {
NODE_ENV,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"nanoid": "3.3.4",
"pm2": "^5.3.0",
"redis": "^4.6.13",
"util": "^0.12.5"
"util": "^0.12.5",
"wait-on": "^7.2.0"
},
"devDependencies": {
"artillery": "^2.0.12",
Expand Down
57 changes: 45 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d434a78

Please sign in to comment.