sokko-g/.forgejo/workflows/validate-main.yml
Shinuwa 067a4a8fd6
Some checks failed
Validate and deploy Sokko G / validate (push) Failing after 19m40s
Validate and deploy Sokko G / deploy (push) Has been skipped
Fix the audit's concurrency, stale state and delivery findings
Share uploads now reserve their slot, bytes and per-IP count before the
disk check, so simultaneous uploads can no longer exceed the limits.
Writes to a share's metadata run one after another, and a revocation can
no longer be undone by a pending read count.

The TCG page ignores a state reload that started before or during a
mutation, the last mutation wins, and returning to the page triggers a
single reload. The card cache confirms writes only once the IndexedDB
transaction completes and shows only the current player's copy. The
administration panel loads on demand, which shrinks the TCG chunk from
311.6 to 191.8 kB.

A new /api/health route answers 503 when the cards or shares API failed
to start. The deploy script ships the commit's production dependencies
with the build, waits up to 30 s for a healthy server instead of trusting
systemctl is-active, and restores node_modules on rollback. Both Forgejo
workflows check the route on the public site. The updated script applies
once reinstalled on the server.

Unused helpers, the ignored join role and duplicate button selectors are
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 21:38:20 +01:00

128 lines
4.9 KiB
YAML

# Rôle : valide chaque commit poussé sur main puis livre automatiquement le dernier SHA validé.
name: Validate and deploy Sokko G
on:
push:
branches:
- main
jobs:
validate:
runs-on: docker
container: "mcr.microsoft.com/playwright:v1.62.1-noble@sha256:dcc5531e97840b9b5e794f2814476b21571c5124a3fca2267d73041f56e7580e"
outputs:
commit: ${{ steps.commit.outputs.sha }}
steps:
- name: Check out the pushed commit
uses: https://data.forgejo.org/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: ${{ gitea.sha }}
persist-credentials: false
- name: Set up the pinned Node version
uses: https://data.forgejo.org/actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 24.11.1
cache: npm
- name: Set up the pinned npm version
run: npm install --global npm@11.17.0
- name: Record the pushed commit
id: commit
env:
PUSHED_COMMIT: ${{ gitea.sha }}
run: |
commit="$(git rev-parse HEAD)"
test "$commit" = "$PUSHED_COMMIT"
printf 'sha=%s\n' "$commit" >> "$GITHUB_OUTPUT"
- name: Install dependencies from the lockfile
run: npm ci
- name: Run the complete validation gate
run: npm run check:full
deploy:
needs: validate
runs-on: docker
env:
DEPLOY_COMMIT: ${{ needs.validate.outputs.commit }}
steps:
- name: Check out the current main head
uses: https://data.forgejo.org/actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
ref: main
persist-credentials: false
- name: Check whether the validated commit is still current
id: freshness
run: |
current_commit="$(git rev-parse HEAD)"
deploy=false
if test "$current_commit" = "$DEPLOY_COMMIT"; then
deploy=true
else
printf 'Skipping stale commit %s; main is now %s.\n' "$DEPLOY_COMMIT" "$current_commit"
fi
printf 'deploy=%s\n' "$deploy" >> "$GITHUB_OUTPUT"
- name: Install the deployment clients
if: steps.freshness.outputs.deploy == 'true'
run: |
if ! command -v ssh >/dev/null 2>&1 || ! command -v curl >/dev/null 2>&1; then
apt-get update
apt-get install -y --no-install-recommends curl openssh-client
fi
- name: Configure the pinned production host key
if: steps.freshness.outputs.deploy == 'true'
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_SSH_KNOWN_HOSTS: ${{ secrets.DEPLOY_SSH_KNOWN_HOSTS }}
run: |
test -n "$DEPLOY_SSH_KEY"
test -n "$DEPLOY_SSH_KNOWN_HOSTS"
umask 077
mkdir -p "$HOME/.ssh"
printf '%s\n' "$DEPLOY_SSH_KEY" > "$HOME/.ssh/id_ed25519"
printf '%s\n' "$DEPLOY_SSH_KNOWN_HOSTS" > "$HOME/.ssh/known_hosts"
ssh-keygen -F '[webapps.shinuwa.fr]:2911' -f "$HOME/.ssh/known_hosts" >/dev/null
- name: Verify the remote deployment contract
if: steps.freshness.outputs.deploy == 'true'
run: |
contract="$(ssh -o BatchMode=yes -o StrictHostKeyChecking=yes \
-o UserKnownHostsFile="$HOME/.ssh/known_hosts" \
-i "$HOME/.ssh/id_ed25519" -p 2911 shinuwa@webapps.shinuwa.fr \
'cat /usr/local/share/sokko-g/deploy-contract')"
test "$contract" = 'exact-commit-v1'
- name: Deploy the validated commit
if: steps.freshness.outputs.deploy == 'true'
run: |
ssh -o BatchMode=yes -o StrictHostKeyChecking=yes \
-o UserKnownHostsFile="$HOME/.ssh/known_hosts" \
-i "$HOME/.ssh/id_ed25519" -p 2911 shinuwa@webapps.shinuwa.fr \
"sudo /usr/local/bin/deploy-sokko-g --commit '$DEPLOY_COMMIT'"
- name: Verify the deployed commit and public origin
if: steps.freshness.outputs.deploy == 'true'
run: |
deployed_commit="$(ssh -o BatchMode=yes -o StrictHostKeyChecking=yes \
-o UserKnownHostsFile="$HOME/.ssh/known_hosts" \
-i "$HOME/.ssh/id_ed25519" -p 2911 shinuwa@webapps.shinuwa.fr \
'sudo -u shinuwa git -C /data/webapps/sites/sokko-g rev-parse HEAD')"
test "$deployed_commit" = "$DEPLOY_COMMIT"
curl --fail --silent --show-error --retry 5 --retry-all-errors \
--retry-delay 2 https://sokkog.shinuwa.fr/ >/dev/null
curl --fail --silent --show-error --retry 5 --retry-all-errors \
--retry-delay 2 https://sokkog.shinuwa.fr/data/site.json >/dev/null
curl --fail --silent --show-error --retry 5 --retry-all-errors \
--retry-delay 2 https://sokkog.shinuwa.fr/api/health | grep -Fq '"ok":true'
- name: Remove the deployment key
if: always()
run: rm -f "$HOME/.ssh/id_ed25519"