Skip to content

Commit d1b2c1d

Browse files
authored
Merge pull request #88 from umc-commit/feat/ci-cd-pipeline
[FEAT] CI/CD pipeline 생성
2 parents 0806b3b + c73340a commit d1b2c1d

File tree

6 files changed

+949
-8
lines changed

6 files changed

+949
-8
lines changed

.github/workflows/cd.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Configure SSH
18+
run: |
19+
mkdir -p ~/.ssh
20+
echo "$EC2_SSH_KEY" > ~/.ssh/id_rsa
21+
chmod 600 ~/.ssh/id_rsa
22+
23+
cat >>~/.ssh/config <<END
24+
Host ec2
25+
HostName $EC2_HOST
26+
User ubuntu
27+
IdentityFile ~/.ssh/id_rsa
28+
StrictHostKeyChecking no
29+
END
30+
env:
31+
EC2_HOST: ${{ secrets.EC2_HOST }}
32+
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}
33+
34+
- name: Copy code to EC2
35+
run: |
36+
ssh ec2 "sudo mkdir -p /opt/app && sudo chown ubuntu:ubuntu /opt/app"
37+
scp -r ./ ec2:/opt/app
38+
39+
- name: Create .env file
40+
run: |
41+
ssh ec2 "echo '$ENV_FILE' > /opt/app/.env"
42+
env:
43+
ENV_FILE: ${{ secrets.ENV_FILE }}
44+
45+
- name: Install dependencies
46+
run: ssh ec2 "cd /opt/app && npm install"
47+
48+
- name: Restart systemd service
49+
run: ssh ec2 "sudo systemctl restart app"

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [develop]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
19+
- name: Install dependencies
20+
run: npm install
21+
22+
- name: Run Linter
23+
run: npm run lint
24+
25+
- name: Run Tests
26+
run: npm test

eslint.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import { defineConfig } from "eslint/config";
4+
5+
export default defineConfig([
6+
{
7+
files: ["**/*.{js,mjs,cjs}"],
8+
plugins: { js },
9+
extends: ["js/recommended"],
10+
languageOptions: {
11+
globals: {
12+
...globals.node,
13+
...globals.browser,
14+
},
15+
},
16+
rules: {
17+
"no-unused-vars": "off",
18+
},
19+
},
20+
]);

0 commit comments

Comments
 (0)