demo.yml

 1name: Update Demo VHS
 2
 3on:
 4  workflow_dispatch:
 5  release:
 6    types: [published]
 7
 8permissions:
 9  contents: write
10  pull-requests: write
11
12jobs:
13  update-demo:
14    if: github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false
15    name: Generate and Update Demo GIF
16    runs-on: ubuntu-latest
17    steps:
18      - name: Checkout code
19        uses: actions/checkout@v6
20        with:
21          persist-credentials: false
22
23      - name: Set up Go
24        uses: actions/setup-go@v6
25        with:
26          go-version: "stable"
27
28      - name: Create Dummy Config
29        # Create the config in the workspace so we can map HOME to it for the container.
30        run: |
31          mkdir -p ~/.config/matcha
32          cat <<EOF > ~/.config/matcha/config.json
33          {
34            "accounts": [
35              {
36                "id": "demo-user",
37                "name": "Matcha Client",
38                "email": "matcha@floatpane.com",
39                "password": "dummy-password",
40                "service_provider": "custom",
41                "fetch_email": "matcha@floatpane.com"
42              }
43            ]
44          }
45          EOF
46      - name: Build Matcha
47        env:
48          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49        run: |
50          LATEST_TAG=$(gh release view --json tagName -q ".tagName")
51          echo "Found latest release: $LATEST_TAG"
52
53          git fetch --tags
54
55          COMMIT=$(git rev-parse --short HEAD)
56          DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
57          go build -ldflags="-s -w -X main.version=$LATEST_TAG -X main.commit=$COMMIT -X main.date=$DATE" -o matcha .
58
59      - name: Prepare Tape
60        # Patch the tape to run the compiled binary instead of "go run ."
61        # This works seamlessly because the typing of this command is 'Hidden' in your tape.
62        run: sed -i 's/go run ./.\/matcha/' demo.tape
63
64      - name: Run VHS'
65        env:
66          CLICOLOR_FORCE: "1"
67        run: |
68          sudo apt update
69          sudo apt install -y ffmpeg ttyd
70          mkdir -p ~/.local/share/fonts
71          wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/JetBrainsMono.zip
72          unzip -o JetBrainsMono.zip -d ~/.local/share/fonts
73          fc-cache -fv
74          go install github.com/charmbracelet/vhs@latest
75          TERM=xterm-256color vhs demo.tape
76
77      - name: Move GIF to Assets
78        run: sudo mv demo.gif public/assets/demo.gif
79
80      - name: Create Pull Request
81        uses: peter-evans/create-pull-request@v8
82        with:
83          token: ${{ secrets.GITHUB_TOKEN }}
84          commit-message: "docs: update demo.gif from release [skip ci]"
85          title: "docs: update demo.gif"
86          body: |
87            This PR updates the demo GIF based on the latest release version.
88            Generated automatically by the Update Demo VHS workflow.
89          branch: "update-demo-gif"
90          base: "master"
91          add-paths: public/assets/demo.gif