feat: Improve Code Generation and Update Entities #15
This file contains hidden or 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 VM | |
on: | |
push: | |
branches: | |
- master # Adjust this to your deployment branch | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: indrafajar/nest-pos-be:latest # Update this | |
- name: Deploy to VM | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.VM_SSH_KEY }} | |
HOST: ${{ secrets.VM_HOST }} # Update with your VM IP | |
USER: ${{ secrets.VM_USERNAME }} | |
run: | | |
echo "${SSH_PRIVATE_KEY}" > /tmp/vm_key | |
chmod 600 /tmp/vm_key | |
ssh -o StrictHostKeyChecking=no -i /tmp/vm_key $USER@$HOST << 'EOF' | |
docker pull indrafajar/nest-pos-be:latest | |
docker stop mynest || true | |
docker rm mynest || true | |
docker run -d --name mynest --env-file ~/nest-pos-be/.env --restart unless-stopped --network pos-app -p 3000:3000 indrafajar/nest-pos-be:latest | |
docker image prune -f | |
EOF |