-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from BokDoong/main
feat: 깃 액션 디벨롭에 넣기
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# 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/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 |