Add .gitea/workflows/deploy.yml
This commit is contained in:
82
.gitea/workflows/deploy.yml
Normal file
82
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,82 @@
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
host:
|
||||
required: true
|
||||
type: string
|
||||
username:
|
||||
required: true
|
||||
type: string
|
||||
port:
|
||||
required: true
|
||||
type: number
|
||||
project_folder:
|
||||
required: true
|
||||
type: string
|
||||
pm2_id:
|
||||
required: true
|
||||
type: string
|
||||
branch_name:
|
||||
required: true
|
||||
type: string
|
||||
tech:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
secrets:
|
||||
password:
|
||||
required: false
|
||||
key:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ inputs.host }}
|
||||
username: ${{ inputs.username }}
|
||||
password: ${{ secrets.password }}
|
||||
key: ${{ secrets.key }}
|
||||
port: ${{ inputs.port }}
|
||||
|
||||
script: |
|
||||
set -xe
|
||||
|
||||
cd ${{ inputs.project_folder }}
|
||||
|
||||
git fetch
|
||||
git reset --hard origin/${{ inputs.branch_name }}
|
||||
git pull origin ${{ inputs.branch_name }}
|
||||
|
||||
echo "Installing deps"
|
||||
npm install
|
||||
|
||||
echo "Running tech-specific steps"
|
||||
case "${{ inputs.tech }}" in
|
||||
node)
|
||||
npm i
|
||||
npx prisma generate
|
||||
npx prisma migrate deploy
|
||||
npm run build
|
||||
pm2 reload ${{ inputs.pm2_id }}
|
||||
;;
|
||||
nestjs)
|
||||
npm i
|
||||
npx prisma generate
|
||||
npx prisma migrate deploy
|
||||
npm run build
|
||||
pm2 reload ${{ inputs.pm2_id }}
|
||||
;;
|
||||
python)
|
||||
docker-compose up -d --build
|
||||
;;
|
||||
*)
|
||||
echo "Unknown tech"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user