-
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 pull request #4 from local-mood/feat/3-cicd
Feat: CI/CD 설정
- Loading branch information
Showing
2 changed files
with
58 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,54 @@ | ||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
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@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
|
||
- name: Make application-secret.yaml | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application-secret.yml | ||
echo "${{ secrets.APPLICATION_SECRET }}" > ./application-secret.yml | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew clean build -x test | ||
- name: Docker build & push to docker repo | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_NAME }} -p ${{ secrets.DOCKER_PW }} | ||
docker build -f Dockerfile -t ${{ secrets.DOCKER_NAME }}/${{ secrets.DOCKER_REPO }} . | ||
docker push ${{ secrets.DOCKER_NAME }}/${{ secrets.DOCKER_REPO }} | ||
- name: Deploy to server | ||
uses: appleboy/ssh-action@master | ||
id: deploy | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.KEY }} | ||
envs: GITHUB_SHA | ||
script: | | ||
sudo docker rm -f $(docker ps -qa) | ||
sudo docker pull ${{ secrets.DOCKER_NAME }}/${{ secrets.DOCKER_REPO }} | ||
docker-compose up -d | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM openjdk:17 | ||
ARG JAR_FILE=/build/libs/*.jar | ||
COPY ${JAR_FILE} app.jar | ||
ENTRYPOINT ["java","-jar", "/app.jar"] |