From 397cf4c7a2bed3439f5c3fb4e70acc3a9df7a269 Mon Sep 17 00:00:00 2001 From: "Adrien W." Date: Sun, 4 Oct 2026 18:55:48 +0200 Subject: [PATCH] Added gitea CI config --- .gitea/workflows/deploy.yml | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..6af5b51 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,66 @@ +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 + 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" \ + "bash /opt/deploy/mon-app.sh '$SHA'" \ No newline at end of file