-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c2755a
commit 74b1150
Showing
1 changed file
with
91 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,91 @@ | ||
# 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: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
|
||
- name: Copy application.yml | ||
env: | ||
OCCUPY_DEPLOY: ${{ secrets.OCCUPY_DEPLOY }} | ||
OCCUPY_DEPLOY_DIR: src/main/resources | ||
OCCUPY_DEPLOY_TEST_DIR: src/test/resources | ||
OCCUPY_DEPLOY_DIR_FILE_NAME: application.yml | ||
run: | | ||
cd ./src/main | ||
mkdir resources | ||
cd ./resources | ||
touch ./application.yml | ||
echo "$OCCUPY_DEPLOY" > ./application.yml | ||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 | ||
with: | ||
arguments: clean build | ||
|
||
## docker build & push to production | ||
- name: Docker build & push to prod | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t minchogt/fu-eureka . | ||
docker push minchogt/fu-eureka | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: cicdsample | ||
path: build/libs/*.jar | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: cicdsample | ||
|
||
- name: Setup SSH | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
## deploy to production | ||
- name: Deploy to prod | ||
uses: appleboy/ssh-action@master | ||
id: deploy-prod | ||
with: | ||
host: ${{ secrets.SERVER_IP }} | ||
username: ${{ secrets.SSH_USER }} | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
sudo docker rm fu-eureka | ||
sudo docker pull minchogt/fu-eureka | ||
docker-compose up -d fu-eureka | ||
docker image prune -f | ||