|
| 1 | +name: Check theme keys |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 9 * * 1" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + issues: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + check: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Fetch upstream Ghostty theme filenames |
| 19 | + env: |
| 20 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + run: | |
| 22 | + curl -s -H "Authorization: Bearer $GH_TOKEN" \ |
| 23 | + "https://api.github.com/repos/mbadolato/iTerm2-Color-Schemes/contents/ghostty" \ |
| 24 | + | jq -r '.[].name' | sort > upstream.txt |
| 25 | + count=$(wc -l < upstream.txt) |
| 26 | + if [ "$count" -lt 100 ]; then |
| 27 | + echo "Upstream fetch returned only $count themes — aborting." |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + echo "Fetched $count upstream themes." |
| 31 | +
|
| 32 | + - name: Extract mixer theme keys |
| 33 | + run: | |
| 34 | + awk '/const themes = \[/,/^ \];/' index.html \ |
| 35 | + | grep -oE 'key: "[^"]+"' \ |
| 36 | + | sed -E 's/key: "(.+)"/\1/' \ |
| 37 | + | sort -u > mixer.txt |
| 38 | + echo "Found $(wc -l < mixer.txt) keys in mixer:" |
| 39 | + cat mixer.txt |
| 40 | +
|
| 41 | + - name: Compare |
| 42 | + id: diff |
| 43 | + run: | |
| 44 | + missing=$(comm -23 mixer.txt upstream.txt) |
| 45 | + if [ -n "$missing" ]; then |
| 46 | + echo "=== DRIFT DETECTED ===" |
| 47 | + echo "$missing" |
| 48 | + { |
| 49 | + echo "missing<<EOF" |
| 50 | + echo "$missing" |
| 51 | + echo "EOF" |
| 52 | + } >> "$GITHUB_OUTPUT" |
| 53 | + else |
| 54 | + echo "All mixer keys match upstream." |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Open or update issue |
| 58 | + if: steps.diff.outputs.missing != '' |
| 59 | + uses: actions/github-script@v7 |
| 60 | + with: |
| 61 | + script: | |
| 62 | + const missing = process.env.MISSING.trim(); |
| 63 | + const body = [ |
| 64 | + "The weekly theme-drift check found `key` values in `index.html` that no longer match any file in Ghostty's upstream themes (sourced from [iTerm2-Color-Schemes/ghostty](https://github.com/mbadolato/iTerm2-Color-Schemes/tree/master/ghostty)).", |
| 65 | + "", |
| 66 | + "**Keys that no longer resolve:**", |
| 67 | + "```", |
| 68 | + missing, |
| 69 | + "```", |
| 70 | + "", |
| 71 | + "Fix: update the `key` values in the `themes` array in `index.html` so each matches an existing filename upstream.", |
| 72 | + "", |
| 73 | + "Verify locally: `ls /Applications/Ghostty.app/Contents/Resources/ghostty/themes/`", |
| 74 | + ].join("\n"); |
| 75 | +
|
| 76 | + const { data: existing } = await github.rest.issues.listForRepo({ |
| 77 | + owner: context.repo.owner, |
| 78 | + repo: context.repo.repo, |
| 79 | + state: 'open', |
| 80 | + labels: 'theme-drift', |
| 81 | + }); |
| 82 | +
|
| 83 | + if (existing.length > 0) { |
| 84 | + await github.rest.issues.createComment({ |
| 85 | + owner: context.repo.owner, |
| 86 | + repo: context.repo.repo, |
| 87 | + issue_number: existing[0].number, |
| 88 | + body, |
| 89 | + }); |
| 90 | + core.info(`Commented on existing issue #${existing[0].number}`); |
| 91 | + } else { |
| 92 | + const { data: issue } = await github.rest.issues.create({ |
| 93 | + owner: context.repo.owner, |
| 94 | + repo: context.repo.repo, |
| 95 | + title: 'Theme keys out of sync with Ghostty upstream', |
| 96 | + body, |
| 97 | + labels: ['theme-drift'], |
| 98 | + }); |
| 99 | + core.info(`Opened issue #${issue.number}`); |
| 100 | + } |
| 101 | + env: |
| 102 | + MISSING: ${{ steps.diff.outputs.missing }} |
0 commit comments