Skip to content

Commit

Permalink
Create deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Alextopher authored Oct 14, 2024
1 parent dfc7654 commit b53b6d7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Deploy Docker to VPS

on:
workflow_dispatch:
push:
branches: [ "main" ]

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v4

- name: Build the Docker image
run: docker build --tag tvhsfrc:latest .

- name: Save Docker image to file
run: docker save tvhsfrc:latest -o image.tar

- name: Upload Docker image to VPS
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.VPS_SSH_KEY }}
source: image.tar
target: ~/image.tar

- name: Deploy!
uses: appleboy/ssh-action@v1.1.0
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.VPS_SSH_KEY }}
port: 22
script: |
docker load -i ~/image.tar
docker stop tvhsfrc || true
docker rm tvhsfrc || true
docker run -d --name tvhsfrc -p 8000:80 tvhsfrc:latest

0 comments on commit b53b6d7

Please sign in to comment.