fix: yml 설정 오탈자 수정 #41
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: | |
- main | |
jobs: | |
build_and_deploy: | |
name: Deploy CD | |
runs-on: ubuntu-latest | |
steps: | |
- name: 레포지토리를 가져온다 | |
uses: actions/checkout@v4 | |
- name: 자바 17을 설치한다 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Gradle 명령 실행을 위해 권한을 부여한다 | |
run: chmod +x gradlew | |
- name: Gradle 로 build 를 수행한다 | |
run: ./gradlew clean build | |
- name: Docker Hub 로그인 | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: 환경변수 파일 생성 | |
run: echo "${{ secrets.APPLICATION_ENV }}" > ./.env | |
- name: 환경변수 파일을 서버로 전송한다 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
port: ${{ secrets.PORT }} | |
source: "./.env" | |
target: "./" | |
# - name: ubuntu Docker image build and push | |
# run: | | |
# docker-compose -f ./docker/docker-compose.yml build | |
# docker-compose -f ./docker/docker-compose.yml push | |
- name: ubuntu Docker image build | |
run: docker build -t ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:latest -f Dockerfile-server . | |
- name: Redis Docker image build | |
run: docker build -t ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:redis -f Dockerfile-redis . | |
- name: ubuntu docker Hub 푸쉬 | |
run: docker push ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:latest | |
- name: Redis docker Hub 푸쉬 | |
run: docker push ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:redis | |
- name: Deploy with push | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
port: ${{ secrets.PORT }} | |
# 이미 멈춰있어서 발생하는 예외를 방지하기 위해 || true 설정 | |
script: | | |
sudo docker stop we-share-wish-hair || true | |
sudo docker stop wswh-redis || true | |
sudo docker container prune -f | |
sudo docker pull ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:latest | |
sudo docker run -d --log-driver=syslog --env-file .env \ | |
-p 8080:8080 --name we-share-wish-hair \ | |
${{ secrets.DOCKER_NAME }}/we-share-wish-hair:latest | |
sudo docker pull ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:redis | |
sudo docker run -d -p 6379:6379 --name wswh-redis ${{ secrets.DOCKER_NAME }}/we-share-wish-hair:redis | |