Skip to content

Commit

Permalink
[ci/cd] #2 github actions 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
SunYerim committed Jun 13, 2024
1 parent 74b7e5c commit e1d744f
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Auth CI/CD

on:
push:
branches: [ main ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Clear Gradle cache
run: rm -rf ~/.gradle/caches/

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build --no-daemon

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/sunjoo:auth .
docker push ${{ secrets.DOCKER_USERNAME }}/sunjoo:auth
- name: SSH and Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/sunjoo:auth
docker stop sunjoo || true
docker rm sunjoo || true
docker run -d -p 8082:8082 --name sunjoo ${{ secrets.DOCKER_USERNAME }}/sunjoo:auth

0 comments on commit e1d744f

Please sign in to comment.