Skip to content

Commit

Permalink
[Chore] - deploy.yml ์ƒ์„ฑ
Browse files Browse the repository at this point in the history
  • Loading branch information
Minn-Choi authored Nov 4, 2024
1 parent 320d2a2 commit d2c3010
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# deploy.yml
name: Deploy Vue.js to EC2

on:
push:
branches:
- main # main ๋ธŒ๋žœ์น˜์— push๋  ๋•Œ ํŠธ๋ฆฌ๊ฑฐ

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Build Docker image
run: docker build -t ${{ secrets.DOCKER_USERNAME }}/my-vue-app .

- name: Push Docker image to Docker Hub
run: |
docker tag ${{ secrets.DOCKER_USERNAME }}/my-vue-app:latest ${{ secrets.DOCKER_USERNAME }}/my-vue-app:latest
docker push ${{ secrets.DOCKER_USERNAME }}/my-vue-app:latest
deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@v0.1.3
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
port: 22
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/my-vue-app:latest
docker stop my-vue-app || true
docker rm my-vue-app || true
docker run -d -p 80:80 โ€”name my-vue-app ${{ secrets.DOCKER_USERNAME }}/my-vue-app:latest

0 comments on commit d2c3010

Please sign in to comment.