feat : 6자 이상 입력으로 수정 #49
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
name: Deploy frontend to EC2 | |
on: | |
push: | |
paths: | |
- "frontend/**" | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Create .env file | |
run: | | |
echo "SOCKET_IP"=${{ secrets.SOCKET_IP }} > ./frontend/.env | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/worry-is-bubble-frontend:latest ./frontend | |
docker push ${{ secrets.DOCKER_USERNAME }}/worry-is-bubble-frontend:latest | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
script: | | |
docker pull ${{ secrets.DOCKER_USERNAME }}/worry-is-bubble-frontend:latest | |
docker stop worry-is-bubble-frontend || true | |
docker rm worry-is-bubble-frontend || true | |
docker run -d --name worry-is-bubble-frontend -p 80:80 ${{ secrets.DOCKER_USERNAME }}/worry-is-bubble-frontend:latest |