Update deploy.yml #18
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 VPS | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
run: | | |
docker build -t price-calc:latest . | |
docker save price-calc:latest > price-calc.tar | |
chmod 664 price-calc.tar | |
- name: Transfer Docker image to VPS | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.VPS_HOST }} | |
username: ${{ secrets.VPS_USERNAME }} | |
key: ${{ secrets.VPS_SSH }} | |
port: ${{ secrets.VPS_PORT }} | |
source: "price-calc.tar" | |
target: "/tmp" | |
- name: Deploy to VPS | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.VPS_HOST }} | |
username: ${{ secrets.VPS_USERNAME }} | |
key: ${{ secrets.VPS_SSH }} | |
port: ${{ secrets.VPS_PORT }} | |
script: | | |
docker load < /tmp/price-calc.tar | |
docker stop price-calc || true | |
docker rm price-calc || true | |
docker run -d --name price-calc -p 8003:8003 price-calc:latest |