Files
client160_IHMKOS/.gitea/workflows/deploy-canary.yml
T

92 lines
3.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: deploy-canary
on:
push:
branches: [ main ]
paths:
- "app.py"
- "config.py"
- "templates/**"
- ".gitea/workflows/deploy-canary.yml"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Force LAN host mapping (ephagit & srv)
run: |
echo "10.90.0.10 ephagit.ephaitek.com" >> /etc/hosts
echo "10.10.0.10 srv.ephaitek.com" >> /etc/hosts
getent hosts ephagit.ephaitek.com
getent hosts srv.ephaitek.com
- name: Debug réseau/Git (non bloquant)
shell: bash
continue-on-error: true
run: |
set -xeuo pipefail
git --version
getent hosts ephagit.ephaitek.com
getent hosts srv.ephaitek.com
curl -sI https://ephagit.ephaitek.com/ | head -n1 || true
- name: Test flux réseau (runner -> Gitea & srv)
shell: bash
run: |
set -e
echo "== Résolution DNS =="
getent hosts ephagit.ephaitek.com || true
getent hosts srv.ephaitek.com || true
echo "== HTTPS vers Gitea =="
curl -sI https://ephagit.ephaitek.com | head -n1
echo "== TCP 2224 vers srv =="
# pas besoin de nc : on utilise /dev/tcp de bash
if timeout 5 bash -c 'cat < /dev/null > /dev/tcp/srv.ephaitek.com/2224'; then
echo "OK: port 2224 ouvert vers srv"
else
echo "KO: port 2224 inaccessible depuis le conteneur"; exit 2
fi
- name: Checkout (shallow + token)
uses: actions/checkout@v4
with:
# token: ${{ secrets.CHECKOUT_TOKEN }} # ton PAT
fetch-depth: 1 # évite l’historique complet
# optionnel : ne sortir que les dossiers utiles au déploiement
sparse-checkout: |
app.py
config.py
templates
static
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Deploy to CANARY
uses: appleboy/ssh-action@v1.0.3
env: # <- crée la variable côté runner
DEPLOY_PULL_TOKEN: ${{ secrets.DEPLOY_PULL_TOKEN }}
with:
host: ${{ secrets.SSH_HOST }} # srv.ephaitek.com
port: ${{ secrets.SSH_PORT }} # 2224
username: ${{ secrets.SSH_USER }} # deployer
key: ${{ secrets.SSH_KEY }}
envs: DEPLOY_PULL_TOKEN
script: |
set -euo pipefail
# (au cas où) éviter "dubious ownership" si ça réapparaît
git config --global --add safe.directory /srv/ihm/app/IHMKOS || true
# Auth HTTPS non interactive via .netrc (éphémère)
umask 077
cat > ~/.netrc <<EOF
machine ephagit.ephaitek.com
login moham
password ${DEPLOY_PULL_TOKEN}
EOF
# Pull du code
git -C /srv/ihm/app/IHMKOS pull --rebase --ff-only
# Nettoyage
rm -f ~/.netrc
# Redémarrer le canary
/srv/ihm/scripts/docker-run-canary.sh