Skip to content

Merge pull request #43 from yj-leez/yj-leez #10

Merge pull request #43 from yj-leez/yj-leez

Merge pull request #43 from yj-leez/yj-leez #10

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches:
- yj-leez
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up NTP
run: |
sudo apt-get update
sudo apt-get install -y ntp
sudo service ntp start
- name: make application-db.properties
run: |
cd ./src/main/resources
touch ./application-db.properties
echo "${{ secrets.DB_PROPERTIES }}" > ./application-db.properties
shell: bash
- name: make application-real.properties
run: |
cd ./src/main/resources
touch ./application-real.properties
echo "${{ secrets.PROPERTIES_PROD }}" > ./application-real.properties
shell: bash
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build -x test
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t app -f Dockerfile .
docker tag app ${{ secrets.DOCKER_USERNAME }}/ceos-18th:latest
docker push ${{ secrets.DOCKER_USERNAME }}/ceos-18th:latest
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD }} # EC2 인스턴스 퍼블릭 DNS
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }} # pem 키
# 도커 작업
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/ceos-18th:latest
docker stop $(docker ps -a -q)
docker-compose up -d
docker image prune -a -f
- name: Build with Gradle
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0
with:
arguments: build