Skip to content

Merge pull request #100 from git1uv/feature/#95 #53

Merge pull request #100 from git1uv/feature/#95

Merge pull request #100 from git1uv/feature/#95 #53

Workflow file for this run

name: Java CI/CD with Gradle
on:
push:
branches: [ "develop" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle Wrapper
run: ./gradlew clean build --exclude-task test --warning-mode all
# DockerHub Login
- name: docker login
uses: docker/login-action@v2
with:
username: cowboysj
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v4.0.0
with:
context: .
file: ./Dockerfile
push: true
build-args: |
DB_URL=${{ secrets.DB_URL }} \
DB_USER=${{ secrets.DB_USER }} \
DB_PW=${{ secrets.DB_PW }} \
DB_ROOTPW=${{ secrets.DB_ROOTPW }} \
JWT_SECRET=${{ secrets.JWT_SECRET }} \
OAUTH_ID=${{ secrets.OAUTH_ID }} \
OAUTH_PW=${{ secrets.OAUTH_PW }} \
KAKAO_ID=${{ secrets.KAKAO_ID }} \
KAKAO_URI=${{ secrets.KAKAO_URI }} \
KAKAO_SECRET=${{ secrets.KAKAO_SECRET }} \
MAIL_NAME=${{ secrets.MAIL_NAME }} \
MAIL_PW=${{ secrets.MAIL_PW }} \
CLAUDE_API_KEY=${{ secrets.CLAUDE_API_KEY }} \
SERVER_URL=${{ secrets.SERVER_URL }} \
JAVA_HOME=/usr/local/openjdk-21 \
tags: cowboysj/simter:latest
- name: Deploy on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_IP }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.AWS_EC2_SSH_KEY }}
port: 22
script: |
sudo docker pull cowboysj/simter:latest
sudo docker stop simter-container
sudo docker rm simter-container
sudo docker run -d -p 8080:8080 --name simter-container -e DB_URL=${{ secrets.DB_URL }} -e DB_USER=${{ secrets.DB_USER }} -e DB_PW=${{ secrets.DB_PW }} -e DB_ROOTPW=${{ secrets.DB_ROOTPW }} -e JWT_SECRET=${{ secrets.JWT_SECRET }} -e OAUTH_ID=${{ secrets.OAUTH_ID }} -e OAUTH_PW=${{ secrets.OAUTH_PW }} -e KAKAO_ID=${{ secrets.KAKAO_ID }} -e KAKAO_URI=${{ secrets.KAKAO_URI }} -e KAKAO_SECRET=${{ secrets.KAKAO_SECRET }} -e MAIL_NAME=${{ secrets.MAIL_NAME }} -e MAIL_PW=${{ secrets.MAIL_PW }} -e CLAUDE_API_KEY=${{ secrets.CLAUDE_API_KEY }} -e SERVER_URL=${{ secrets.SERVER_URL }} -e JAVA_HOME=/usr/local/openjdk-21 cowboysj/simter:latest