Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/workflows/tessl-update.yml
Original file line number Diff line number Diff line change
@@ -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
)"
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`
Expand Down