Skip to content

Commit

Permalink
Merge pull request #82 from PUDDY-sp/main
Browse files Browse the repository at this point in the history
update deploy.yml
  • Loading branch information
Jang99u authored Feb 10, 2024
2 parents db691fa + 8dd6d64 commit f1ba050
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
67 changes: 67 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Java CI with Gradle

on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]

jobs:
build:
runs-on: ubuntu-22.04
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Create Secret Config file
run: |
cd src/main/resources
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml
- name: Setup Gradle
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0

- name: Build with Gradle Wrapper
run: ./gradlew build -x test

- name: Set up Docker Buildx
uses: docker/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
file: ../../Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_PROD_REPONAME }}:0.0.1

deploy:
needs: [build]
runs-on: ubuntu-22.04

steps:
- name: Docker Image Pull and Container Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ 22 }}
script: |
docker compose down
docker image prune -a
docker compose up
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ out/
.DS_Store
.vscode/

src/main/resources/
src/main/resources/application-local.yml
src/main/resources/application-prod.yml
9 changes: 9 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spring.profiles.default: local

---

spring.config.active.on-profile: local

---

spring.config.active.on-profile: prod

0 comments on commit f1ba050

Please sign in to comment.