mirror of
https://github.com/thedrewen/protojx-manager.git
synced 2026-03-21 01:48:54 +01:00
feat(deploy): add GitHub Actions workflow for deployment to VPS
This commit is contained in:
52
.github/workflows/deploy.yml
vendored
Normal file
52
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# This is a basic workflow to help you get started with Actions
|
||||||
|
name: Deploy
|
||||||
|
|
||||||
|
# Controls when the workflow will run
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||||
|
jobs:
|
||||||
|
# This workflow contains a single job called "build"
|
||||||
|
build:
|
||||||
|
# The type of runner that the job will run on
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||||
|
steps:
|
||||||
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup SSH Agent
|
||||||
|
uses: webfactory/ssh-agent@v0.9.0
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Add VPS to known_hosts
|
||||||
|
run: |
|
||||||
|
ssh-keyscan -p ${{ secrets.VPS_PORT }} -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
- name: Deploy to VPS
|
||||||
|
run: |
|
||||||
|
ssh -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} "
|
||||||
|
cd /home/${{ secrets.VPS_USER }}/protojx/protojx-manager &&
|
||||||
|
git pull &&
|
||||||
|
|
||||||
|
# Stop and remove old container if exists
|
||||||
|
docker stop protojx_manager 2>/dev/null || true &&
|
||||||
|
docker rm protojx_manager 2>/dev/null || true &&
|
||||||
|
|
||||||
|
# Build new image
|
||||||
|
docker buildx build -t protojx_manager . &&
|
||||||
|
|
||||||
|
# Run new container
|
||||||
|
docker run -d \
|
||||||
|
--name protojx_manager \
|
||||||
|
--restart unless-stopped \
|
||||||
|
--network shared \
|
||||||
|
protojx_manager
|
||||||
|
"
|
||||||
@@ -7,4 +7,6 @@ COPY . .
|
|||||||
RUN apt-get update && apt-get install -y iputils-ping
|
RUN apt-get update && apt-get install -y iputils-ping
|
||||||
RUN npm i
|
RUN npm i
|
||||||
|
|
||||||
|
RUN npm register
|
||||||
|
|
||||||
CMD [ "npm", "run", "start" ]
|
CMD [ "npm", "run", "start" ]
|
||||||
Reference in New Issue
Block a user