Skip to content

Commit 4b80897

Browse files
authored
🔖 v0.1.2 (#65)
2 parents 760ffdf + 5b7b777 commit 4b80897

22 files changed

Lines changed: 3948 additions & 1292 deletions

File tree

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
name: Next.js Build Test
22

33
on:
4-
# Runs on pushes targeting the default branch
5-
push:
6-
branches: [ "main" ]
7-
84
# Runs on any open or reopened pull request
95
pull_request:
10-
types: [ opened, reopened ]
6+
types: [ opened, reopened, synchronize ]
117

128
# Allows you to run this workflow manually from the Actions tab
139
workflow_dispatch:
@@ -26,7 +22,7 @@ concurrency:
2622

2723
jobs:
2824
# Build job
29-
build:
25+
build-test:
3026
runs-on: ubuntu-latest
3127
env:
3228
API_BASE_URL: ${{ secrets.API_BASE_URL }}

.github/workflows/deploy.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: read
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Checkout config repository
20+
uses: actions/checkout@v4
21+
with:
22+
repository: Camus-chat/config
23+
path: config
24+
token: ${{ secrets.GH_PAT }}
25+
26+
- name: Copy .env file
27+
run: cp config/frontend/.env .env
28+
29+
- name: Build Docker image
30+
run: |
31+
docker build -t camus-frontend:latest .
32+
33+
- name: Log in to Amazon ECR
34+
env:
35+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
36+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
37+
AWS_ECR_URL: ${{ secrets.AWS_ECR_URL }}
38+
AWS_REGION: ${{ secrets.AWS_REGION }}
39+
run: |
40+
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ECR_URL
41+
42+
- name: Tag & Push Docker image to ECR
43+
env:
44+
ECR_REPO_URI: ${{ secrets.AWS_ECR_URL }}/camus-fe
45+
run: |
46+
docker tag camus-frontend:latest $ECR_REPO_URI:latest
47+
docker push $ECR_REPO_URI:latest
48+
49+
deploy:
50+
runs-on: ubuntu-latest
51+
needs: build
52+
env:
53+
ECR_REPO_URI: ${{ secrets.AWS_ECR_URL }}/camus-fe
54+
55+
steps:
56+
- name: Deploy Docker container to EC2
57+
uses: appleboy/ssh-action@master
58+
with:
59+
host: ${{ secrets.EC2_HOST }}
60+
username: ${{ secrets.EC2_USER }}
61+
key: ${{ secrets.EC2_KEY }}
62+
script: |
63+
docker pull $ECR_REPO_URI:latest
64+
docker stop frontend || true
65+
docker rm frontend || true
66+
docker run -d -p 3000:3000 --name frontend $ECR_REPO_URI:latest

0 commit comments

Comments
 (0)