Added gitea CI config
This commit is contained in:
66
.gitea/workflows/deploy.yml
Normal file
66
.gitea/workflows/deploy.yml
Normal file
@@ -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'"
|
||||||
Reference in New Issue
Block a user