Skip to content

Merge pull request #80 from everymeals/feature/store-get-detail #22

Merge pull request #80 from everymeals/feature/store-get-detail

Merge pull request #80 from everymeals/feature/store-get-detail #22

Workflow file for this run

name: CD for Dev
on:
push:
branches: [ "develop" ]
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
steps:
# 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
- uses: actions/checkout@v3
# 2) JDK 17 버전 설치
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'zulu'
# 3) Gradle Caching
- name: Gradle Cashing
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 4) Gradle 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# 5) Set for application-secret.yml
- name: Make application-secret.yml
run: |
cd ./src/main/resources
touch ./application-secret.yml
echo "${{ secrets.PROPERTIES_SECRET }}" > ./application-secret.yml
shell: bash
- name: Make application-dev.yml
run: |
cd ./src/main/resources
touch ./application-dev.yml
echo "${{ secrets.PROPERTIES_SECRET_DEV }}" > ./application-dev.yml
shell: bash
- name: Make application-prod.yml
run: |
cd ./src/main/resources
touch ./application-prod.yml
echo "${{ secrets.PROPERTIES_SECRET_PROD }}" > ./application-prod.yml
shell: bash
# 6) 빌드
- name: Build with gradle
run: ./gradlew bootJar
# 7) Docker 빌드 & 푸쉬
- name: docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}}
# 9) Deploy (DEV-Server)
- name: Deploy (DEV)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
docker stop dev
docker rm dev
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}}
sudo docker run -d --name dev -v /var/log/app:/var/log/app -v /etc/localtime:/etc/localtime:ro -e TZ=Asia/Seoul -e ENVIRONMENT_VALUE=-Dspring.profiles.active=dev -p 8085:8080 ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY}}:latest
docker rmi -f $(docker images -f "dangling=true" -q)