update: config service docker ip #6
This file contains hidden or 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: GOGO Stage stage CD Workflow | |
| on: | |
| push: | |
| branches: | |
| - 'develop' | |
| workflow_dispatch: | |
| jobs: | |
| CI: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v2 | |
| - name: Setup Gradle's permission | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew clean build | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: CI | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Install sshpass | |
| run: sudo apt-get update && sudo apt-get install -y sshpass | |
| - name: SSH Command to Deploy using Password | |
| run: | | |
| sshpass -p "${{ secrets.SSH_PASSWORD }}" ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF' | |
| mkdir -p /home/ubuntu/gogo-stage | |
| cd /home/ubuntu/gogo-stage | |
| if [ ! -d ".git" ]; then | |
| git clone -b develop https://github.com/team-gogo/gogo-stage.git . | |
| else | |
| git pull origin develop | |
| fi | |
| ./gradlew build | |
| docker build -f DockerFileStage -t gogo-stage-stage . | |
| docker stop gogo-stage-stage || true | |
| docker rm gogo-stage-stage || true | |
| docker run -d -p 8082:8082 --name gogo-stage-stage gogo-stage-stage | |
| EOF | |
| - name: SSH Success Notification | |
| if: success() | |
| uses: sarisia/actions-status-discord@v1 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| color: 0x4CAF50 | |
| title: "배포 성공" | |
| message: "GOGO Stage stage deployment completed successfully." | |
| - name: SSH Failure Notification | |
| if: failure() | |
| uses: sarisia/actions-status-discord@v1 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| color: 0xFF4C4C | |
| title: "배포 실패" | |
| message: "GOGO Stage stage deployment failed. Check the logs for details." |