Merge remote-tracking branch 'origin/dev' into dev #16
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
# 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: [ "dev" ] | |
pull_request: | |
branches: [ "dev" ] | |
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-gateway . | |
docker push minchogt/fu-gateway | |
- 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-gateway | |
sudo docker pull minchogt/fu-gateway | |
docker-compose up -d gateway | |
docker image prune -f | |