Skip to content

fix(badges): médaillons ×N / ÷N lisibles et cohérents (fin des emojis) #162

fix(badges): médaillons ×N / ÷N lisibles et cohérents (fin des emojis)

fix(badges): médaillons ×N / ÷N lisibles et cohérents (fin des emojis) #162

Workflow file for this run

name: Deploy branch preview
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: write
pull-requests: write
concurrency:
# Serialize gh-pages writes across all preview jobs AND the main deploy,
# otherwise two jobs can race on the same branch.
group: gh-pages
cancel-in-progress: false
# Voir le commentaire dans deploy.yml — opt-in Node 24 pour peaceiris@v4.
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
# Slug = branch name with any non-alphanumeric char collapsed to `-`.
# Example: `claude/document-leitner-choice-9dMPQ`
# -> `claude-document-leitner-choice-9dMPQ`
- name: Compute preview slug
id: slug
run: |
raw='${{ github.head_ref }}'
slug=$(echo "$raw" | tr -c 'a-zA-Z0-9-' '-' | tr -s '-' | sed 's/^-\|-$//g')
echo "slug=$slug" >> "$GITHUB_OUTPUT"
echo "base=/previews/$slug/" >> "$GITHUB_OUTPUT"
- run: npm ci
- run: npm run build
env:
BASE: ${{ steps.slug.outputs.base }}
- run: npx playwright install --with-deps chromium
- run: npm run user-guide
env:
# Required so the preview server serves at the same base as the
# built assets, and the user-guide script navigates to the right URL.
BASE: ${{ steps.slug.outputs.base }}
# Marker poll-able from GitHub Pages once it's actually serving the
# fresh build. Used by the wait step below — without it, the PR
# comment lands before Pages has finished propagating, and clicking
# the link gives a 404 (or stale content on subsequent pushes).
- name: Write deployment marker
run: echo "${{ github.event.pull_request.head.sha }}" > dist/.preview-sha
- name: Publish to gh-pages (previews/${{ steps.slug.outputs.slug }})
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
publish_branch: gh-pages
destination_dir: previews/${{ steps.slug.outputs.slug }}
keep_files: true
commit_message: 'preview: ${{ steps.slug.outputs.slug }} @ ${{ github.event.pull_request.head.sha }}'
- name: Wait for GitHub Pages to serve fresh preview
env:
EXPECTED_SHA: ${{ github.event.pull_request.head.sha }}
SLUG: ${{ steps.slug.outputs.slug }}
run: |
url="https://tablito.app/previews/$SLUG/.preview-sha"
for i in $(seq 1 60); do
actual=$(curl -fsSL "$url" 2>/dev/null | tr -d '[:space:]' || true)
if [ "$actual" = "$EXPECTED_SHA" ]; then
echo "Preview live with $EXPECTED_SHA after ${i}×5s"
exit 0
fi
echo "Attempt $i/60: got '$actual', want '$EXPECTED_SHA'"
sleep 5
done
echo "::warning::Preview did not become live with the expected SHA in 5 minutes — comment posted anyway"
# Wrapped in wretry parce que l'API GitHub issues renvoie parfois un
# 504 transitoire sur ce step (cf. run 24829541258). 3 tentatives
# espacées de 10 s suffisent dans quasi tous les cas.
- name: Comment PR with preview links
uses: Wandalen/wretry.action@v3.8.0
with:
action: marocchino/sticky-pull-request-comment@v2
attempt_limit: 3
attempt_delay: 10000
with: |
header: preview-${{ steps.slug.outputs.slug }}
message: |
**Preview déployée** pour cette PR :
- App : https://tablito.app/previews/${{ steps.slug.outputs.slug }}/
- Guide : https://tablito.app/previews/${{ steps.slug.outputs.slug }}/guide/
Commit : `${{ github.event.pull_request.head.sha }}`
_Le preview est mis à jour à chaque push et supprimé à la fermeture de la PR._