fix: docker build tag 수정 #23
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: | |
# pull_request: | |
# branches: [dev] | |
# types: [closed] | |
push: | |
branches: [refactor/cd-flow] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged | |
steps: | |
- name: 체크아웃 | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- name: JDK 11 설치 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: '11' | |
cache: 'gradle' | |
- name: Gradle에 실행 권한 부여 | |
run: chmod +x gradlew | |
- name: 빌드 | |
run: ./gradlew build -x test | |
- name: DockerHub 로그인 | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker 이미지 빌드 & DockerHub에 Push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
- name: EC2 서버에 배포 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.STG_SERVER_HOST }} | |
username: ${{ secrets.STG_SERVER_USERNAME }} | |
key: ${{ secrets.STG_SERVER_PEM_KEY }} | |
envs: GITHUB_SHA | |
script: | | |
sudo docker stop $(sudo docker ps -a -q) | |
sudo docker pull ${{secrets.DOCKER_USERNAME}}/qtudy-server | |
sudo docker run -d -p 8080:8080 --name qtudy-server-container ${{secrets.DOCKER_USERNAME}}/qtudy-server | |
sudo docker image prune -f |