P48: le manutenzioni ricorrenti diventano una procedura leggibile #90
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and publish Trust Center | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "tenants/**" | |
| - "core/**" | |
| - "content/**" | |
| - "default-tenant.json" | |
| - "site/**" | |
| - "package.json" | |
| - ".github/workflows/publish.yml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - run: npm ci | |
| - run: npm run validate | |
| - run: npm run score | |
| - run: npm run build-site | |
| # Rigenera manutenzione.json, che il pannello di gestione legge per dire | |
| # a chi lo apre cosa c'è da fare. Sta qui e non solo nel giro settimanale | |
| # delle evidenze perché i passi delle procedure vivono nel registro: una | |
| # correzione a un passo deve arrivare al pannello col push che la fa, non | |
| # il lunedì dopo. | |
| - run: npm run build-cadences | |
| # P45 F5 — genera il sito della RADICE (la pagina del prodotto) e le sue | |
| # copie di compatibilità site/badge.svg e site/score.json. Senza questo | |
| # step la radice pubblicherebbe le sole copie committate: il badge, che | |
| # 22 punti pubblici incorporano, si congelerebbe in silenzio al valore | |
| # dell'ultimo commit invece di seguire il punteggio reale. Stessa falla | |
| # già trovata su build-changelog in P44 F6. | |
| - run: npm run build-root | |
| # Rigenera site/changelog.html da content/changelog.yaml: senza questo | |
| # step il sito pubblicherebbe la sola copia rigenerata a mano in locale, | |
| # e un changelog dimenticato non farebbe diventare rosso nulla. | |
| - run: npm run build-changelog | |
| # P45 F3 — pubblica il Trust Center del tenant sul suo repo Pages sottile. | |
| # Esiste perché GitHub Pages ammette un solo dominio custom per | |
| # repository: il sottodominio del tenant non è ottenibile da questo repo, | |
| # che pubblica già la radice trust.spaziogenesi.org. | |
| # Sta PRIMA della pubblicazione della radice di proposito: la radice | |
| # riassume i punteggi dei tenant, quindi il tenant si aggiorna per primo. | |
| # ⚠️ Niente action di terze parti: git push diretto col PAT, stesso | |
| # schema di deploy-staging.yml in imgauthweb. | |
| # ⚠️ Il file CNAME (dominio custom del sottodominio) è scritto qui da | |
| # P45 F4, dopo che il record DNS esiste: GitHub Pages da branch legge il | |
| # CNAME nella cartella pubblicata, e senza di esso il rsync --delete | |
| # cancellerebbe quello scritto da GitHub, perdendo il dominio custom al | |
| # primo deploy. L'host si ricava da tenant.config.json › site.public_url, | |
| # così un nuovo tenant (P46) non deve toccare questo workflow. | |
| - name: Pubblica il Trust Center del tenant sul suo repo Pages | |
| env: | |
| TRUST_TENANT_DEPLOY_TOKEN: ${{ secrets.TRUST_TENANT_DEPLOY_TOKEN }} | |
| run: | | |
| set -e | |
| if [ -z "$TRUST_TENANT_DEPLOY_TOKEN" ]; then | |
| echo "::error::Secret TRUST_TENANT_DEPLOY_TOKEN mancante: il Trust Center del tenant non verrebbe pubblicato." | |
| exit 1 | |
| fi | |
| TENANT="${GTF_TENANT:-$(node -p "require('./default-tenant.json').id")}" | |
| SRC="tenants/${TENANT}/site" | |
| REPO="$(node -p "require('./tenants/${TENANT}/tenant.config.json').site.publish_repo")" | |
| test -f "${SRC}/index.html" | |
| HOST="$(node -p "new URL(require('./tenants/${TENANT}/tenant.config.json').site.public_url).hostname")" | |
| echo "$HOST" > "${SRC}/CNAME" | |
| echo "Pubblico ${SRC} su ${REPO} (dominio custom ${HOST})" | |
| rm -rf /tmp/trust-tenant | |
| git clone --depth 1 "https://x-access-token:${TRUST_TENANT_DEPLOY_TOKEN}@github.com/${REPO}.git" /tmp/trust-tenant | |
| # Sostituzione completa, non un merge: un file rimasto da un build | |
| # precedente non sparirebbe mai. README.md è escluso perché è | |
| # l'avvertenza "non modificare qui" del repo, non contenuto | |
| # pubblicato (Pages serve index.html, non il README). | |
| rsync -a --delete --exclude='.git' --exclude='README.md' "${SRC}/" /tmp/trust-tenant/ | |
| cd /tmp/trust-tenant | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "deploy: Trust Center ${TENANT} da gtf@${{ github.sha }}" || echo "Nessuna modifica da pubblicare." | |
| git push origin main | |
| # P45 F5 — la radice pubblica ora il sito del PRODOTTO. ./site contiene | |
| # l'index.html scritto da build-root.mjs, le copie di compatibilità | |
| # badge.svg e score.json (impegno pubblico: quegli URL non si spostano), | |
| # il changelog generato e le pagine statiche mai spostate | |
| # (devops.html, whitepaper.html, whitepaper-v1.0.pdf, la verifica motori). | |
| # Il Trust Center del tenant vive sul suo host, pubblicato dallo step qui | |
| # sopra. Lo step di assemblaggio transitorio F1→F5 è stato rimosso qui. | |
| - uses: actions/configure-pages@v5 | |
| - uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./site | |
| - id: deployment | |
| uses: actions/deploy-pages@v4 |