-
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.
Merge branch 'main' of https://github.com/StudyFlexUMC5th/StudyFlex-BE
- Loading branch information
Showing
25 changed files
with
583 additions
and
174 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: 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 17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
## gradle caching | ||
- name: Gradle Caching | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
## create application-prod.properties | ||
- name: make application-prod.properties | ||
if: contains(github.ref, 'main') # branch가 main 일 때, 나머지는 위와 동일 | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application-prod.properties | ||
echo "${{ secrets.PROPERTIES_PROD }}" > ./application-prod.properties | ||
shell: bash | ||
|
||
## gradle build | ||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
## docker build & push to production | ||
- name: Docker build & push to prod | ||
if: contains(github.ref, 'main') | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile-prod -t ${{ secrets.DOCKER_USERNAME }}/studyflex . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/studyflex | ||
|
||
## deploy to production | ||
- name: Deploy to prod | ||
uses: appleboy/ssh-action@master | ||
id: deploy-prod | ||
if: contains(github.ref, 'main') | ||
with: | ||
host: ${{ secrets.HOST_PROD }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
sudo docker stop studyflex | ||
sudo docker rm studyflex | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/studyflex | ||
sudo docker run -d -p 8080:8080 --name studyflex ${{ secrets.DOCKER_USERNAME }}/studyflex | ||
sudo docker image prune -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
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 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 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
Oops, something went wrong.