Skip to content

Merge pull request #37 from Minn-Choi/feature/#6 #4

Merge pull request #37 from Minn-Choi/feature/#6

Merge pull request #37 from Minn-Choi/feature/#6 #4

Workflow file for this run

# 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/[email protected]
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