Skip to content

Merge pull request #45 from BokDoong/notice_feature #11

Merge pull request #45 from BokDoong/notice_feature

Merge pull request #45 from BokDoong/notice_feature #11

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:
- develop
pull_request:
branches:
- develop
permissions:
contents: read
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
## jdk setting
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin' # https://github.com/actions/setup-java
## gradle caching
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.yml') }}
restore-keys: |
${{ runner.os }}-gradle-
## create application-dev.yml
- name: make application-dev.yml
if: contains(github.ref, 'develop')
run: |
cd ./src/main
mkdir resources
cd ./resources
touch ./application-dev.yml
echo "${{ secrets.YML_DEV }}" > ./application-dev.yml
shell: bash
## gradle build
- name: Build with Gradle
run: ./gradlew build -x test
## docker build & push to develop
- name: Docker build & push to dev
if: contains(github.ref, 'develop')
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_REPO }}/fairytale-dev .
docker push ${{ secrets.DOCKER_REPO }}/fairytale-dev
## deploy to develop
- name: Deploy to dev
uses: appleboy/ssh-action@master
id: deploy-dev
if: contains(github.ref, 'develop')
with:
host: ${{ secrets.HOST_DEV }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
port: 22
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}/fairytale-dev
docker run -itd -p 8080:8080 ${{ secrets.DOCKER_REPO }}/fairytale-dev