chore: fix typos on deploy github action #6
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 to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Build and push Docker image | |
run: | | |
docker build -t bolhadev-chat --build-arg PROJECT=server . | |
docker tag whatsapp-newsletter:latest ${{ env.DOCKER_REPO}}:latest | |
docker login -u ${{ env.DOCKER_USERNAME }} -p ${{secrets.DOCKER_TOEKEN}} | |
docker push ${{ env.DOCKER_REPO}}:latest | |
- name: SSH into EC2 instance and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.MY_EC2_SSH_KEY }} | |
script: | | |
sudo docker pull ${{ env.DOCKER_REPO }}:latest | |
sudo docker stop my-node-app || true | |
sudo docker rm my-node-app || true | |
sudo docker run -d -p 3000:3000 --name my-node-app ${{ env.DOCKER_REPO }}:latest |