Skip to content

Commit

Permalink
[fix] : ssh action 수행 시 key로 인증하도록 변경 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 authored Aug 1, 2024
1 parent cc8e067 commit 70a0ee4
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ permissions:
contents: read

jobs:
build:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

# 자바 버전 설정
- name: Set up JDK 17
Expand All @@ -24,7 +25,7 @@ jobs:
- name: Generate application.yml
run: |
mkdir -p ./src/main/resources
echo "${{ secrets.APPLICATION_CORE }}" | base64 -d > ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_YML }}" | base64 -d > ./src/main/resources/application.yml
# gradle 권한 부여
- name: Grant execute permission for gradlew
Expand All @@ -46,28 +47,30 @@ jobs:
- name: Build with Gradle
run: ./gradlew build -x test


# 도커 허브 로그인
- name: Docker Hub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}


# 도커 이미지 빌드 및 푸시
- name: docker image build and push
run: |
docker build -f Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }} .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }}
deploy:
needs: build-and-push-image
runs-on: ubuntu-latest
steps:
# 서버 백그라운드 실행
- name: pull image and run container
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
password: ${{ secrets.EC2_PASSWORD }}
key: ${{ secrets.EC2_KEY }}
port: ${{ secrets.EC2_PORT }}
script: |
cd compose
Expand Down

0 comments on commit 70a0ee4

Please sign in to comment.