fix: cicd.yml container명 변경 #10
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: Gateway CI/CD | |
on: | |
push: | |
branches: [ main ] | |
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 | |
- 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 }}/gateway:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/gateway:latest | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@v0.1.5 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd /home/ubuntu/sunjoo-server-gateway | |
docker-compose down | |
docker pull ${{ secrets.DOCKER_USERNAME }}/gateway:latest | |
docker-compose build | |
docker-compose up -d | |
docker network connect eureka-network sunjoo-server-gateway_gateway_1 | |
docker restart sunjoo-server-gateway_gateway_1 |