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

Feat/alpha env #547

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
60 changes: 60 additions & 0 deletions .github/workflows/backend-build-alpha-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Build Alpha Image

on:
push:
branches: [ develop ]
paths: backend/**
permissions:
id-token: write
jobs:
push-image:
defaults:
run:
working-directory: backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: check jar file
run: ls -l build/libs
- name: Build Image
run: docker build .
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::791335373803:role/AWSPushImageToECR
aws-region: ap-northeast-2

- name: Amazon ECR "Login" Action for GitHub Actions
id: login-ecr
uses: aws-actions/[email protected]

- name: push ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: zipgo/alpha-backend
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG

- name: Docker Login
run: |
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.ECR_LOGIN_PASSWORD }}
- name: CD on EC2
uses: zip-go/[email protected]
with:
instanceName: ${{ secrets.ALPHA_INSTANCE_NAME }}
workingDirectory: ${{ secrets.ALPHA_WORKING_DIRECTORY }}
commands: |
rm .env
echo IMAGE_TAG=${{ github.sha }} > .env
docker compose restart zipgo-backend
38 changes: 16 additions & 22 deletions .github/workflows/frontend-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
push:
branches:
- develop
- feat/alpha-env
paths:
- frontend/**
- .github/**

permissions:
id-token: write
jobs:
build-dockerfile:
defaults:
Expand Down Expand Up @@ -58,29 +60,21 @@ jobs:
context: ./frontend
file: ./frontend/Dockerfile.dev
push: true
tags: ${{ secrets.FRONTEND_IMAGE_NAME }}:latest
tags: ${{ secrets.FRONTEND_ALPHA_IMAGE_NAME }}:latest
platforms: |
linux/amd64
linux/arm64

deploy-to-develop-EC2:
needs: build-dockerfile
runs-on: front-dev-server

steps:
- name: Deploy to Develop EC2
run: |
docker stop ${{ secrets.FRONTEND_CONTAINER_NAME }} || true
docker rm ${{ secrets.FRONTEND_CONTAINER_NAME }} || true
docker pull ${{ secrets.FRONTEND_IMAGE_NAME }}:latest
docker run -d -p 3000:3000 --name ${{ secrets.FRONTEND_CONTAINER_NAME }} ${{ secrets.FRONTEND_IMAGE_NAME }}:latest

- name: Slack Notification
uses: 8398a7/action-slack@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::791335373803:role/SendCommandToEc2FromGithub
aws-region: ${{ secrets.AWS_REGION }}
- name: CD on EC2
uses: zip-go/[email protected]
with:
status: ${{ job.status }}
author_name: 프론트엔드 배포 알림
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
instanceName: ${{ secrets.ALPHA_INSTANCE_NAME }}
workingDirectory: ${{ secrets.ALPHA_WORKING_DIRECTORY }}
commands: |
docker compose restart zipgo-frontend
echo "Succeeded: $GITHUB_SHA" > result.txt
6 changes: 3 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches: [ main, develop ]
paths: backend/**
pull_request:
branches: [ main, develop ]
paths: backend/**
# pull_request:
# branches: [ main, develop ]
# paths: backend/**

jobs:
build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches: [main, develop]
paths: frontend/**
pull_request:
branches: [main, develop]
paths: frontend/**
# pull_request:
# branches: [main, develop]
# paths: frontend/**

jobs:
storybook-test:
Expand Down
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build/

**/src/main/resources/static/docs/
src/main/resources/env.properties
env*.properties

### STS ###
.apt_generated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ version: '3'

services:
mysql:
container_name: zipgo
container_name: zipgo-mysql
image: mysql/mysql-server
environment:
MYSQL_DATABASE: zipgo-mysql
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: root
TZ: 'Asia/Seoul'
ports:
- 13306:3306
- "13306:3306"
command:
- "mysqld"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"

springboot:
container_name: zipgo-backend
build: .
env_file: "env.dev.properties"
ports:
- "8080:8080"
depends_on:
- mysql
2 changes: 1 addition & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FAST_REFRESH=true
BASE_URL=https://dev.api.zipgo.pet
BASE_URL=http://zipgo-backend
HOMEPAGE=https://dev.zipgo.pet
Loading