From 47781b6fd15deb2a72cfed10d1991a2d11018063 Mon Sep 17 00:00:00 2001 From: Kevin Turcios Date: Thu, 23 Apr 2026 07:42:35 -0500 Subject: [PATCH] feat: add reusable tessl tile update workflow Reads missing tiles from .tessl/missing-tiles.txt, auto-prunes installed ones, and opens a PR when changes are detected. --- .github/workflows/tessl-update.yml | 95 ++++++++++++++++++++++++++++++ README.md | 39 ++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 .github/workflows/tessl-update.yml diff --git a/.github/workflows/tessl-update.yml b/.github/workflows/tessl-update.yml new file mode 100644 index 0000000..8494702 --- /dev/null +++ b/.github/workflows/tessl-update.yml @@ -0,0 +1,95 @@ +# Reusable workflow for keeping tessl tiles up to date. +# +# Runs `tessl update` on existing tiles and attempts to install tiles +# listed in `.tessl/missing-tiles.txt` (one tile per line, # comments). +# Successfully installed tiles are removed from the file automatically. +# Opens a PR when changes are detected. +# +# Usage: +# +# jobs: +# tessl: +# uses: codeflash-ai/github-workflows/.github/workflows/tessl-update.yml@main +# secrets: +# TESSL_TOKEN: ${{ secrets.TESSL_TOKEN }} + +name: Tessl Tile Updates + +on: + workflow_call: + secrets: + TESSL_TOKEN: + required: true + +permissions: + contents: write + pull-requests: write + +jobs: + update-tiles: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: tesslio/setup-tessl@v2 + with: + token: ${{ secrets.TESSL_TOKEN }} + + - name: Update existing tiles + run: tessl update --yes + + - name: Attempt to install missing tiles + run: | + missing_file=".tessl/missing-tiles.txt" + if [ ! -f "$missing_file" ]; then + echo "No missing tiles file found, skipping" + exit 0 + fi + installed=() + while IFS= read -r tile || [ -n "$tile" ]; do + [ -z "$tile" ] && continue + [[ "$tile" == \#* ]] && continue + if tessl install --yes "$tile" 2>&1; then + installed+=("$tile") + fi + done < "$missing_file" + for tile in "${installed[@]}"; do + grep -v "^${tile}$" "$missing_file" > "$missing_file.tmp" && mv "$missing_file.tmp" "$missing_file" + done + if ! grep -qE '^[^#[:space:]]' "$missing_file" 2>/dev/null; then + rm "$missing_file" + fi + + - name: Check for changes + id: changes + run: | + if git diff --quiet && git diff --cached --quiet; then + echo "changed=false" >> "$GITHUB_OUTPUT" + else + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Create PR with updates + if: steps.changes.outputs.changed == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + branch="chore/tessl-tile-updates-$(date +%Y%m%d)" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b "$branch" + git add tessl.json .tessl/ + git commit -m "chore: update tessl tiles $(date +%Y-%m-%d)" + git push origin "$branch" + gh pr create \ + --title "chore: update tessl tiles $(date +%Y-%m-%d)" \ + --body "$(cat <<'EOF' +## Summary + +Automated weekly tessl tile update: +- Updated existing tiles to latest versions +- Installed newly available tiles for project dependencies + +Generated by the **tessl-update** workflow. +EOF + )" diff --git a/README.md b/README.md index 7d2d72e..a770094 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,45 @@ jobs: DATABASE_URL: ${{ secrets.DATABASE_URL }} ``` +### `tessl-update.yml` + +Reusable workflow for keeping [tessl](https://tessl.io) tiles up to date. Updates existing tiles and attempts to install tiles listed in `.tessl/missing-tiles.txt`. Opens a PR when changes are detected. + +**Secrets:** + +| Secret | Required | Description | +|---|---|---| +| `TESSL_TOKEN` | Yes | Tessl API token for the workspace | + +**Missing tiles file (`.tessl/missing-tiles.txt`):** + +One tile per line, `#` comments supported. Successfully installed tiles are removed automatically. When the file is empty it gets deleted. + +``` +# PyPI tiles not yet in the registry +tessl/pypi-tree-sitter-javascript +tessl/pypi-ruff +``` + +**Example:** + +```yaml +name: Tessl Tile Updates + +on: + schedule: + - cron: "0 9 * * 1" + workflow_dispatch: + +jobs: + tessl: + uses: codeflash-ai/github-workflows/.github/workflows/tessl-update.yml@main + secrets: + TESSL_TOKEN: ${{ secrets.TESSL_TOKEN }} +``` + +--- + ## Adding a new workflow 1. Create a new `.yml` file in `.github/workflows/`