-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
48 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,48 @@ | ||
name: Main Workflow | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 저장소 Checkout | ||
uses: actions/checkout@v3 | ||
|
||
## create .yml | ||
- name: make application.yml | ||
run: | | ||
mkdir -p src/main/resources | ||
touch ./src/main/resources/application.yml | ||
echo "${{ secrets.APPLICATION }}" >> ./src/main/resources/application.yml | ||
- name: 스프링부트 애플리케이션 빌드 | ||
run: ./gradlew bootJar | ||
|
||
- name: 도커 이미지 빌드 | ||
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/bookdiary --platform linux/amd64 . | ||
|
||
- name: 도커 로그인 | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: 도커 이미지 push | ||
run: | | ||
docker push ${{ secrets.DOCKER_USERNAME }}/bookdiary | ||
- name: 배포 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_SERVER_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: | | ||
docker stop $(docker ps -a -q) | ||
docker rm -f $(docker ps -qa) | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/bookdiary | ||
docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/bookdiary | ||
docker image prune -f |