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
70 changes: 70 additions & 0 deletions .github/workflows/sync-brightscript-grammar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Sync BrightScript grammar

# Renovate watches dev-docs/src/syntaxes/.version-info (see renovate.json
# customManagers) and opens a PR bumping the `ref:` line when a new release
# of rokucommunity/vscode-brightscript-language is published. This workflow
# fires on that PR, re-fetches the grammar JSON from the new tag, and
# commits the updated file to the PR branch — so a single review/merge
# updates both files atomically.
#
# Also runnable manually via workflow_dispatch in case the auto-commit
# misses (e.g. fork PRs, where GITHUB_TOKEN can't push to the head branch).

on:
pull_request:
paths:
- 'dev-docs/src/syntaxes/.version-info'
workflow_dispatch:
inputs:
ref:
description: 'Upstream tag (e.g. v2.65.0). Defaults to whatever .version-info says.'
required: false
type: string

permissions:
contents: write

jobs:
sync:
runs-on: ubuntu-latest
# Skip on PRs from forks — GITHUB_TOKEN doesn't have push perms there.
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref || github.ref }}
# PAT or a github-app token would also work; default GITHUB_TOKEN
# is sufficient since we're only pushing to the same repo.
token: ${{ secrets.GITHUB_TOKEN }}

- name: Read upstream ref
id: ref
run: |
if [ -n "${{ inputs.ref }}" ]; then
echo "value=${{ inputs.ref }}" >> "$GITHUB_OUTPUT"
else
VALUE=$(awk '/^ref:/ {print $2}' dev-docs/src/syntaxes/.version-info)
if [ -z "$VALUE" ]; then
echo "::error::Could not read ref: from .version-info"
exit 1
fi
echo "value=$VALUE" >> "$GITHUB_OUTPUT"
fi

- name: Fetch grammar from upstream
run: |
curl -fsSL \
"https://raw.githubusercontent.com/rokucommunity/vscode-brightscript-language/${{ steps.ref.outputs.value }}/syntaxes/brightscript.tmLanguage.json" \
-o dev-docs/src/syntaxes/brightscript.tmLanguage.json

- name: Commit if changed
run: |
if git diff --quiet dev-docs/src/syntaxes/brightscript.tmLanguage.json; then
echo "Grammar already matches ${{ steps.ref.outputs.value }} — nothing to commit."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add dev-docs/src/syntaxes/brightscript.tmLanguage.json
git commit -m "sync: brightscript grammar to ${{ steps.ref.outputs.value }}"
git push
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ node_modules
.jellyrock-repo
.shared-ui-repo
package-lock.json

# Vendored upstream grammars — preserve original formatting
**/src/syntaxes/
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"// files.associations": "Stop the markdownlint extension from flagging dotfiles whose first line happens to start with '#'. None of these are markdown.",
"files.associations": {
".prettierignore": "ignore",
".version-info": "yaml"
}
}
17 changes: 17 additions & 0 deletions dev-docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-check
import { readFileSync } from 'node:fs';
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
import remarkGithubAlerts from 'remark-github-alerts';
Expand All @@ -9,6 +10,13 @@ import { fetchSharedUi } from '../shared/fetch-shared-ui.mjs';
await fetchSharedUi();
await fetchDocs('dev');

// BrightScript TextMate grammar vendored from rokucommunity (MIT). Version
// tracked in src/syntaxes/.version-info; sync-brightscript-grammar workflow
// re-fetches when Renovate bumps the ref.
const brightscriptGrammar = JSON.parse(
readFileSync(new URL('./src/syntaxes/brightscript.tmLanguage.json', import.meta.url), 'utf8')
);

// https://astro.build/config
export default defineConfig({
site: 'https://dev.jellyrock.app',
Expand All @@ -17,6 +25,15 @@ export default defineConfig({
title: 'JellyRock Dev Guide',
description: 'Developer documentation for JellyRock, a Jellyfin client for Roku.',
favicon: '/favicon.png',
expressiveCode: {
shiki: {
langs: [brightscriptGrammar],
langAlias: {
brighterscript: 'brightscript',
bs: 'brightscript',
},
},
},
head: [
{
tag: 'script',
Expand Down
11 changes: 11 additions & 0 deletions dev-docs/src/syntaxes/.version-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tracks the upstream source of brightscript.tmLanguage.json. Renovate watches
# this file (see renovate.json customManagers) and opens a PR when a newer
# release of rokucommunity/vscode-brightscript-language is published. The PR
# trigger fires the sync-brightscript-grammar workflow, which re-fetches the
# grammar JSON from the new tag and commits the updated file to the PR branch.
# Result: a single review/merge updates both the version ref AND the grammar.
#
# DO NOT EDIT the ref manually unless you also re-fetch the grammar JSON.

# renovate: datasource=github-releases depName=rokucommunity/vscode-brightscript-language
ref: v2.65.0
Loading
Loading