-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : cicd * fix : modify * fix : modify --------- Co-authored-by: kim ye jin <108534554+dPwls0125@users.noreply.github.com> Co-authored-by: pinetree2 <pinetree3966@naver.com>
- Loading branch information
1 parent
c10a2ef
commit 0c11fef
Showing
2 changed files
with
134 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,72 @@ | ||
# 작업명 | ||
name: CD Pipeline | ||
on: | ||
push: | ||
branches: | ||
- 'develop' | ||
- 'main' | ||
|
||
jobs: | ||
CD: | ||
runs-on: ubuntu-latest | ||
env: | ||
RESOURCE_PATH: ./src/main/resources/application.yml | ||
steps: | ||
## Project JDK 17 Setting | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Set yml file | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: ${{ env.RESOURCE_PATH }} | ||
env: | ||
spring.datasource.url: ${{ secrets.DEV_SERVER_DNS }} | ||
spring.datasource.username: ${{ secrets.DB_USERNAME }} | ||
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | ||
|
||
# Login to ghcr | ||
- name: Login to ghcr | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: pinetree2 | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
# Docker 빌드 생성 및 푸시 | ||
- name: dev Docker build & push | ||
if: contains(github.ref, 'main') || contains(github.ref, 'develop') | ||
run: | | ||
docker build -f Dockerfile -t ghcr.io/onion-city/whatssue_be_v2/whatssue:latest . | ||
docker push ghcr.io/Onion-City/Whatssue_BE_v2/whatssue:latest | ||
# 개발서버 SSH접속 및 배포 | ||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
id: deploy | ||
if: contains(github.ref, 'main') || contains(github.ref, 'develop') | ||
with: | ||
host: ${{ secrets.DEV_SERVER_DNS }} | ||
username: ${{ secrets.DEV_SERVER_USER }} | ||
password: ${{ secrets.DEV_SERVER_PASSWORD }} | ||
port: ${{ secrets.DEV_SERVER_SSH_PORT }} | ||
script: | | ||
echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u pinetree2 --password-stdin | ||
if [ "$(docker ps -aq -f name=whatssue-be)" ]; then | ||
sudo docker stop whatssue-be | ||
sudo docker rm whatssue-be | ||
fi | ||
if [ "$(docker images -q ghcr.io/onion-city/whatssue_be_v2/whatssue)" ]; then | ||
sudo docker rmi ghcr.io/onion-city/whatssue_be_v2/whatssue | ||
fi | ||
sudo docker pull ghcr.io/onion-city/whatssue_be_v2/whatssue:latest | ||
sudo docker stop $(docker ps -a -q) | ||
sudo docker run -d -p 8080:8080 --name whatssue-be ghcr.io/onion-city/whatssue_be_v2/whatssue:latest | ||
sudo docker image prune -a -f |
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,62 @@ | ||
# 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" | ||
- "main" | ||
pull_request: | ||
branches: | ||
- "develop" | ||
- "main" | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
RESOURCE_PATH: ./src/main/resources/application.yml | ||
steps: | ||
## Project JDK 17 Setting | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Set yml file | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: ${{ env.RESOURCE_PATH }} | ||
env: | ||
spring.datasource.url: ${{ secrets.DEV_SERVER_DNS }} | ||
spring.datasource.username: ${{ secrets.DB_USERNAME }} | ||
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: build | ||
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} | ||
|
||
- name: Execute Gradle build | ||
run: ./gradlew build | ||
|
||
- name: Upload Apk | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build 파일 | ||
path: build/libs/whatssue-0.0.1-SNAPSHOT-plain.jar |