-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfc7654
commit b53b6d7
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
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 |