ci: restore build & deploy workflow
This commit is contained in:
parent
b955aca55e
commit
42407c2b98
105
.gitea/workflows/docs.yml
Normal file
105
.gitea/workflows/docs.yml
Normal file
@ -0,0 +1,105 @@
|
||||
name: Build & Deploy docs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '0 3 * * *' # mise à jour nocturne (meta.json des repos plugins)
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
mkdir -p /root/_work/powersync-docs
|
||||
cd /root/_work/powersync-docs
|
||||
git init
|
||||
git remote remove origin 2>/dev/null || true
|
||||
git remote add origin \
|
||||
"https://pakutz79:${{ secrets.MKDOCS_TOKEN }}@git.etm-powersync.fr/pakutz79/powersync-docs.git"
|
||||
git fetch --depth 1 origin HEAD
|
||||
git checkout FETCH_HEAD
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
cd /root/_work/powersync-docs
|
||||
python3 -m pip install --break-system-packages -q -r requirements.txt
|
||||
|
||||
# ── Récupération des JSON depuis les 5 repos drivers ─────────────────
|
||||
- name: Fetch plugin JSON files
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.MKDOCS_TOKEN }}
|
||||
run: |
|
||||
cd /root/_work/powersync-docs
|
||||
GITEA_BASE="https://git.etm-powersync.fr"
|
||||
AUTH_BASE="https://pakutz79:${GITEA_TOKEN}@git.etm-powersync.fr"
|
||||
mkdir -p .plugins-src
|
||||
|
||||
for repo in etm-powersync-plugins etm-powersync-plugins-modbus \
|
||||
nymea-plugins nymea-plugins-modbus nymea-generic; do
|
||||
|
||||
# Branche par défaut via API Gitea (pas de hardcoding main/master)
|
||||
BRANCH=$(curl -sf \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${GITEA_BASE}/api/v1/repos/ETM-Schurig/${repo}" \
|
||||
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('default_branch','main'))" \
|
||||
2>/dev/null) || BRANCH="main"
|
||||
|
||||
echo "→ ${repo} (branche: ${BRANCH})"
|
||||
git clone --depth 1 --branch "${BRANCH}" \
|
||||
"${AUTH_BASE}/ETM-Schurig/${repo}.git" \
|
||||
".plugins-src/${repo}" \
|
||||
|| echo "WARNING: ${repo} introuvable ou inaccessible — ignoré"
|
||||
done
|
||||
|
||||
# ── Génération de la doc ──────────────────────────────────────────────
|
||||
- name: Generate device reference + SUMMARY.md
|
||||
run: |
|
||||
cd /root/_work/powersync-docs
|
||||
python3 scripts/gen_device_reference.py \
|
||||
--src .plugins-src \
|
||||
--docs docs \
|
||||
--lang fr
|
||||
|
||||
# ── Build MkDocs ──────────────────────────────────────────────────────
|
||||
- name: MkDocs build --strict
|
||||
run: |
|
||||
cd /root/_work/powersync-docs
|
||||
mkdocs build --strict
|
||||
|
||||
# ── Vérification idempotence ──────────────────────────────────────────
|
||||
- name: Check generated content is up-to-date
|
||||
run: |
|
||||
cd /root/_work/powersync-docs
|
||||
python3 scripts/gen_device_reference.py \
|
||||
--src .plugins-src \
|
||||
--docs docs \
|
||||
--lang fr \
|
||||
--check
|
||||
|
||||
# ── SSH ───────────────────────────────────────────────────────────────
|
||||
- name: Setup SSH deploy key
|
||||
env:
|
||||
SSH_KEY: ${{ secrets.DOCS_DEPLOY_SSH_KEY }}
|
||||
DEPLOY_HOST: ${{ secrets.DOCS_DEPLOY_HOST }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "${SSH_KEY}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
ssh-keyscan -H "${DEPLOY_HOST}" >> ~/.ssh/known_hosts
|
||||
|
||||
# ── Déploiement ───────────────────────────────────────────────────────
|
||||
- name: Deploy via rsync
|
||||
env:
|
||||
DEPLOY_USER: ${{ secrets.DOCS_DEPLOY_USER }}
|
||||
DEPLOY_HOST: ${{ secrets.DOCS_DEPLOY_HOST }}
|
||||
DEPLOY_PATH: ${{ secrets.DOCS_DEPLOY_PATH }}
|
||||
run: |
|
||||
cd /root/_work/powersync-docs
|
||||
rsync -az --delete \
|
||||
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=yes" \
|
||||
site/ \
|
||||
"${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}"
|
||||
Loading…
x
Reference in New Issue
Block a user