Files
client160_IHMKOS/.gitea/workflows/rollback-prod.yml
T

41 lines
1.3 KiB
YAML

name: rollback-prod
on:
workflow_dispatch:
inputs:
sha:
description: "Commit SHA à restaurer (vide = .rollback_commit)"
required: false
jobs:
rollback:
runs-on: ubuntu-latest
steps:
- name: Rollback via SSH + systemd
uses: appleboy/ssh-action@v1.0.3
env:
SYSTEMD_SERVICE: ${{ vars.SYSTEMD_SERVICE }} # ihm-ephapoc
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
envs: SYSTEMD_SERVICE
script: |
set -euo pipefail
repo=/srv/ihm/app/IHMKOS
svc="${SYSTEMD_SERVICE:-ihm-ephapoc}"
cd "${repo}"
target="${{ inputs.sha }}"
if [ -z "${target}" ] && [ -f .rollback_commit ]; then
target="$(cat .rollback_commit)"
fi
[ -n "${target}" ] || { echo "Aucun commit de rollback disponible"; exit 1; }
git fetch origin main --depth=50 || true
git checkout -f "${target}"
git submodule update --init --recursive || true
sudo -n systemctl restart "${svc}.service"
sudo -n systemctl --no-pager --full status "${svc}.service" -l || true