Files
pardis/.gitea/workflows/deploy.yml
Adrien W. b0aa5acf4b
Some checks failed
Tests et déploiement / deploy (push) Has been cancelled
Tests et déploiement / validate (push) Has been cancelled
Improved import security, added browser tests
2026-10-08 21:34:58 +02:00

72 lines
2.1 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 run validate
npx playwright install --with-deps chromium
npm run test:e2e
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'"