fix: redis port 수정 #18
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: Auth CI/CD | |
on: | |
push: | |
branches: [ develop ] | |
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 pull ${{ secrets.DOCKER_USERNAME }}/sunjoo:redis | |
if [ "$(docker ps -aq -f name=sunjoo-server-auth)" ]; then | |
docker stop sunjoo-server-auth | |
docker rm sunjoo-server-auth | |
fi | |
if [ "$(docker ps -aq -f name=sunjoo-server-redis)" ]; then | |
docker stop sunjoo-server-redis | |
docker rm sunjoo-server-redis | |
fi | |
if [ "$(docker ps -q -f publish=6379)" ]; then | |
docker stop $(docker ps -q -f publish=6379) | |
docker rm $(docker ps -q -f publish=6379) | |
fi | |
docker run -d -p 8080:8090 --name sunjoo-server-auth ${{ secrets.DOCKER_USERNAME }}/sunjoo:auth | |
docker run -d -p 6379:6379 --name sunjoo-server-redis ${{ secrets.DOCKER_USERNAME }}/sunjoo:redis |