Merge PR #132: Add merge-queue skill and document label-driven merge … #33
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: Demo GIF | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| jobs: | |
| record: | |
| # Skip if the push was made by the CI bot to avoid loops. | |
| if: github.actor != 'github-actions[bot]' | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Credentials intentionally persisted — needed for git push. | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 | |
| with: | |
| go-version-file: go.mod | |
| - name: Build mdsmith | |
| run: go build -o mdsmith ./cmd/mdsmith | |
| - name: Cache VHS + ttyd binaries | |
| id: vhs-cache | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: | | |
| ~/vhs-bin | |
| key: vhs-0.10.0-ttyd-1.7.7-${{ runner.os }}-${{ runner.arch }} | |
| - name: Install VHS runtime dependencies | |
| run: | | |
| # Google Chrome is pre-installed on GitHub runners and | |
| # go-rod (used by VHS) finds it via launcher.LookPath(). | |
| # Installing chromium via apt on Ubuntu 24.04 triggers a | |
| # slow snap install (~500 MB of dependencies), so we skip | |
| # it and only install ffmpeg. | |
| sudo apt-get update -qq | |
| sudo apt-get install -y -qq ffmpeg | |
| if [ -f ~/vhs-bin/ttyd ]; then | |
| sudo install ~/vhs-bin/ttyd /usr/local/bin/ttyd | |
| else | |
| curl -fsSL -o /tmp/ttyd \ | |
| "https://github.com/tsl0922/ttyd/releases/download/1.7.7/ttyd.x86_64" | |
| sudo install /tmp/ttyd /usr/local/bin/ttyd | |
| fi | |
| - name: Install VHS | |
| run: | | |
| if [ -f ~/vhs-bin/vhs ]; then | |
| sudo install ~/vhs-bin/vhs /usr/local/bin/vhs | |
| else | |
| go install github.com/charmbracelet/vhs@v0.10.0 | |
| fi | |
| echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH" | |
| - name: Populate VHS cache | |
| if: steps.vhs-cache.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p ~/vhs-bin | |
| cp /usr/local/bin/ttyd ~/vhs-bin/ | |
| cp "$(go env GOPATH)/bin/vhs" ~/vhs-bin/ 2>/dev/null || cp /usr/local/bin/vhs ~/vhs-bin/ 2>/dev/null || true | |
| - name: Record demo in isolated directory | |
| run: | | |
| # Run VHS in a temp directory so demo.tape commands | |
| # cannot modify the repo working tree. | |
| iso="$(mktemp -d)" | |
| tar --exclude='.git' -cf - . | (cd "$iso" && tar -xf -) | |
| # No Output-path rewrite needed — VHS runs inside $iso, | |
| # so relative Output assets/demo.gif writes to $iso/assets/. | |
| (cd "$iso" && vhs demo.tape) | |
| cp "$iso/assets/demo.gif" /tmp/demo.gif | |
| rm -rf "$iso" | |
| - name: Push GIF to assets branch | |
| run: | | |
| # Create or update the orphan assets branch with only | |
| # the demo GIF. This avoids pushing to main entirely — | |
| # no branch protection bypass needed. | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # Remove untracked build artifacts so branch switch succeeds. | |
| rm -f mdsmith | |
| # Check if assets branch exists on remote | |
| if git ls-remote --exit-code origin refs/heads/assets >/dev/null 2>&1; then | |
| git fetch origin assets | |
| git checkout assets | |
| git rm -rf --ignore-unmatch . | |
| git clean -fdx | |
| else | |
| git checkout --orphan assets | |
| git rm -rf --ignore-unmatch . | |
| git clean -fdx | |
| fi | |
| mkdir -p assets | |
| cp /tmp/demo.gif assets/demo.gif | |
| # Only push if the GIF actually changed | |
| git add assets/demo.gif | |
| if git diff --staged --quiet; then | |
| echo "assets/demo.gif unchanged — nothing to push" | |
| else | |
| git commit -m "chore: update demo GIF" | |
| git push -u origin assets | |
| fi |