Update deploy workflow: manual dispatch + track commit
All checks were successful
Deploy / deploy (push) Successful in 6s
All checks were successful
Deploy / deploy (push) Successful in 6s
This commit is contained in:
parent
d2fd88c91e
commit
96873602ef
1 changed files with 13 additions and 2 deletions
|
|
@ -3,6 +3,12 @@ name: Deploy
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
description: "Commit or branch to deploy (default: main)"
|
||||||
|
required: false
|
||||||
|
default: "main"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
|
|
@ -10,13 +16,18 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy via SSH
|
- name: Deploy via SSH
|
||||||
run: |
|
run: |
|
||||||
|
REF="${{ github.event.inputs.ref || github.sha }}"
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
|
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
|
||||||
chmod 600 ~/.ssh/id_ed25519
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
|
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
|
||||||
ssh -o StrictHostKeyChecking=no opc@${{ secrets.DEPLOY_HOST }} << 'ENDSSH'
|
ssh -o StrictHostKeyChecking=no opc@${{ secrets.DEPLOY_HOST }} << ENDSSH
|
||||||
cd /home/opc/services/my-favs
|
cd /home/opc/services/my-favs
|
||||||
git pull
|
git fetch origin
|
||||||
|
git checkout ${REF}
|
||||||
|
git pull origin main || true
|
||||||
sudo docker compose up -d --build
|
sudo docker compose up -d --build
|
||||||
|
echo "${REF}" > .deployed-commit
|
||||||
|
echo "Deployed: ${REF} at $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
ENDSSH
|
ENDSSH
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue