Skip to content

Commit

Permalink
init: Create mainWorkflow.yml
Browse files Browse the repository at this point in the history
main workflow # 1
  • Loading branch information
Relaxed-Mind authored Nov 2, 2023
1 parent 29e3e68 commit fc3e477
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/mainWorkflow.yml
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

0 comments on commit fc3e477

Please sign in to comment.