Merge pull request #47 from f-lab-edu/feature/46-schedule #19
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: CD | |
on: | |
push: | |
branches: [ "master" ] | |
permissions: | |
contents: read | |
jobs: | |
CD: | |
runs-on: ubuntu-latest | |
# 작업 실행단계 | |
steps: | |
# 체크아웃 및 JDK 세팅 | |
- name : Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
# Gradle 권한 부여 | |
- name : Grant Execute permission for gradlew | |
run: chmod +x gradlew | |
shell: bash | |
# application.yml 파일 생성 | |
- name: Make application.yml | |
run: | | |
cd ./src/main/resources | |
touch ./application.yml | |
echo "${{ secrets.APPLICATION_YAML }}" | base64 --decode > ./application.yml | |
shell: bash | |
# Gradle 빌드 (테스트 제외) | |
- name: Build with Gradle | |
run: ./gradlew clean build -x test | |
shell: bash | |
# DockerFile 이미지 작성 및 Docker Repository 업로드 | |
- name: Docker build & Docker push | |
run: | | |
docker login -u ${{ secrets.USERNAME }} -p ${{ secrets.PASSWORD }} | |
docker build -f Dockerfile -t ${{ secrets.USERNAME }}/modoospace . | |
docker push ${{ secrets.USERNAME }}/modoospace | |
# 서버 접속 및 애플리케이션 실행 | |
- name: WAS access & deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.WAS_HOST }} | |
username: ${{ secrets.WAS_USERNAME }} | |
password: ${{ secrets.WAS_PASSWORD }} | |
port: ${{ secrets.WAS_SSH_PORT }} | |
script: | | |
docker stop modoocontainer | |
docker rm modoocontainer | |
docker pull ${{ secrets.USERNAME }}/modoospace | |
docker run -d -p 8080:8080 --name modoocontainer ${{ secrets.USERNAME }}/modoospace |