Merge pull request #50 from MarketPlace-O2O-Platform/feat/#49 #30
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# .gitignore에 있는 properties파일 추가 | |
- name: Add prod_properties | |
run: | | |
mkdir ./src/main/resources | |
touch ./src/main/resources/application.properties | |
echo "${{ secrets.PROPERTIES }}" > ./src/main/resources/application.properties | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
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 | |
# Docker Image Build and Push | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set up Docker Build | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }} | |
# CD 배포 | |
- name: Deploy remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DEPLOYMENT_HOST }} | |
username: ${{ secrets.DEPLOYMENT_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script_stop: true | |
script: | | |
cd marketplace | |
chmod +x ./deploy.sh | |
./deploy.sh |