[#36] Refactor: 사용자가 회원가입 할 때 대학도 저장하도록 한다. #53
Workflow file for this run
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
name: deploy | |
on: | |
push: | |
branches: [ "dev" ] | |
pull_request: | |
branches: [ "dev" ] | |
jobs: | |
develop-cd: | |
# 실행 환경 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# JDK 17 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# gradle caching | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# application-dev.yml | |
- name: Copy dev secret | |
env: | |
DEV_SECRET: ${{ secrets.APPLICATION_DEV_YML }} | |
DEV_SECRET_DIR: src/main/resources | |
DEV_SECRET_DIR_FILE_NAME: application-dev.yml | |
run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME | |
# application-jwt.yml | |
- name: Copy jwt secret | |
env: | |
DEV_SECRET: ${{ secrets.APPLICATION_JWT_YML }} | |
DEV_SECRET_DIR: src/main/resources | |
DEV_SECRET_DIR_FILE_NAME: application-jwt.yml | |
run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME | |
# application-mail.yml | |
- name: Copy mail secret | |
env: | |
DEV_SECRET: ${{ secrets.APPLICATION_MAIL_YML }} | |
DEV_SECRET_DIR: src/main/resources | |
DEV_SECRET_DIR_FILE_NAME: application-mail.yml | |
run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME | |
# application-s3.yml | |
- name: Copy s3 secret | |
env: | |
DEV_SECRET: ${{ secrets.APPLICATION_S3_YML }} | |
DEV_SECRET_DIR: src/main/resources | |
DEV_SECRET_DIR_FILE_NAME: application-s3.yml | |
run: echo $DEV_SECRET | base64 --decode >> $DEV_SECRET_DIR/$DEV_SECRET_DIR_FILE_NAME | |
# ./gradlew 권한 설정 | |
- name: ./gradlew 권한 설정 | |
run: chmod +x ./gradlew | |
# Gradle build (Test 제외) | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
# docker build & push to production | |
- name: Docker build & push to DockerHub | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest | |
# GET GitHub IP | |
- name: get GitHub IP | |
id: ip | |
uses: haythem/public-ip@v1.2 | |
# AWS 세팅 | |
- name: aws 세팅 | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ap-northeast-2 | |
# ADD Github IP to AWS | |
- name: Add GitHub IP to AWS | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
# docker-compose.yml 파일 EC2로 복사 | |
- name: Copy docker-compose.yml to EC2 via SCP | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: 22 | |
source: "./docker-compose.yml" | |
target: "./jedero" | |
# 서버에 접속하여 도커 이미지를 pull 받고 실행하기 | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@v0.1.6 | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: 22 | |
script: | | |
cd jedero | |
sudo docker-compose down | |
sudo docker-compose pull | |
sudo docker-compose up -d | |
sudo docker image prune -f | |
# REMOVE Github IP FROM Security Group | |
- name: Remove IP FROM Security Group | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 |