-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from GPGT-Algorithm-Study/develop
[DEPLOY] 서버 이전을 위한 배포
- Loading branch information
Showing
4 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: "[BUG]" | ||
labels: bug | ||
assignees: fing9 | ||
|
||
--- | ||
|
||
## 어떤 버그인가요? | ||
|
||
> 어떤 버그인지 간결하게 설명해주세요 | ||
## 어떤 상황에서 발생한 버그인가요? | ||
|
||
> (가능하면) Given-When-Then 형식으로 서술해주세요 | ||
## 예상 결과 | ||
|
||
> 예상했던 정상적인 결과가 어떤 것이었는지 설명해주세요 | ||
## 참고할만한 자료(선택) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
name: Common | ||
about: "\b여러 용도의 형태" | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
## 요약 | ||
|
||
## 설명 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: "[FEATURE]" | ||
labels: enhancement | ||
assignees: fing9 | ||
|
||
--- | ||
|
||
## 어떤 기능인가요? | ||
|
||
> 추가하려는 기능에 대해 간결하게 설명해주세요 | ||
## 작업 상세 내용 | ||
|
||
- [ ] TODO | ||
- [ ] TODO | ||
- [ ] TODO | ||
|
||
## 참고할만한 자료(선택) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This workflow will build a Java project with Gradle | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | ||
|
||
name: Spring Boot & Gradle CI/CD 2 | ||
|
||
on: | ||
push: | ||
branches: | ||
- deploy | ||
|
||
jobs: | ||
build: | ||
# 실행 환경 지정 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
# 스프링부트 코드 Build | ||
- name: Build with Gradle | ||
run: ./gradlew clean build -x test | ||
|
||
# 도커 로그인하고 도커 이미지 빌드 후 푸시한다. | ||
- name: web docker build and push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build --platform linux/amd64 -t ${{ secrets.DOCKER_USERNAME }}/randps-back . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/randps-back | ||
# Github Actions IP 가져온다. | ||
- name: Get Github Actions IP | ||
id: ip | ||
uses: haythem/[email protected] | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID2 }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY2 }} | ||
aws-region: ap-northeast-2 | ||
|
||
# Github Actions IP를 AWS 보안그룹에 추가한다. | ||
- name: Add Github Actions IP to Security group | ||
run: | | ||
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID2 }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
# ssh로 EC2 접속해서 도커 컨테이너를 모두 멈춘 후, 도커 파일을 새로 받아 다시 docker-compose로 이미지를 실행시킨다. | ||
- name: executing remote ssh commands using password | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST_IP2 }} | ||
username: ubuntu | ||
key: ${{ secrets.PRIVATE_KEY2 }} | ||
script: | | ||
sudo docker rm -f $(sudo docker ps -qa) | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/randps-back | ||
sudo docker-compose up -d | ||
sudo docker image prune -f | ||
# AWS 보안그룹에서 Github Actions IP를 삭제한다. | ||
- name: Remove Github Actions IP From Security Group | ||
run: | | ||
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID2 }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 |