Files
pardis/.gitea/workflows/deploy.yml
Adrien W. 7130ba5a12
All checks were successful
Tests et déploiement / validate (push) Successful in 47s
Tests et déploiement / deploy (push) Successful in 54s
Fixed gitea CI config
2026-10-04 19:29:02 +02:00

72 lines
2.0 KiB
YAML

name: Tests et déploiement
on:
push:
branches:
- master
jobs:
validate:
runs-on: ci-node
timeout-minutes: 15
steps:
- name: Récupérer le commit
uses: https://github.com/actions/checkout@v4
with:
ref: ${{ gitea.sha }}
persist-credentials: false
- name: Installer et valider
env:
CI: "true"
run: |
set -eu
npm ci
npm test
npm run check
npm run build
deploy:
needs: validate
runs-on: ci-node
timeout-minutes: 20
steps:
- name: Installer le client SSH
run: |
set -eu
apt-get update
apt-get install -y --no-install-recommends openssh-client
- name: Déployer le commit validé
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
SHA: ${{ gitea.sha }}
run: |
set -eu
echo "Préparation de la connexion SSH"
: "${DEPLOY_HOST:?Secret DEPLOY_HOST absent ou vide}"
: "${DEPLOY_USER:?Secret DEPLOY_USER absent ou vide}"
: "${DEPLOY_SSH_KEY:?Secret DEPLOY_SSH_KEY absent ou vide}"
: "${DEPLOY_KNOWN_HOSTS:?Secret DEPLOY_KNOWN_HOSTS absent ou vide}"
: "${SHA:?SHA absent ou vide}"
umask 077
mkdir -p "$HOME/.ssh"
printf '%s\n' "$DEPLOY_SSH_KEY" > "$HOME/.ssh/deploy"
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts"
trap 'rm -f "$HOME/.ssh/deploy"' EXIT
ssh \
-i "$HOME/.ssh/deploy" \
-o IdentitiesOnly=yes \
-o BatchMode=yes \
-o StrictHostKeyChecking=yes \
-o ConnectTimeout=10 \
-o UserKnownHostsFile="$HOME/.ssh/known_hosts" \
"$DEPLOY_USER@$DEPLOY_HOST" \
"echo SSH_OK; bash /opt/pardis/deploy.sh '$SHA'"