Skip to content

Commit 75fd2f9

Browse files
pfeerickclaude
andauthored
feat(ci): clean up submission PR titles and automate image localization (#71)
- Strip the issue-template prefix (and drop the "—" separator) from the auto-generated submission PR title and commit message, so titles read e.g. `feat(scripts): Add EdgeTX Flight Log` instead of `feat(scripts): Add script — [Lua App Submission] EdgeTX Flight Log`. - Add localize-images.yml: applying the `localize-images` label to a submission PR now runs download_external_images.py and auto-commits the result, replacing the manual "run this locally" checklist step. - Add CONTRIBUTING.md documenting the full issue -> PR -> merge pipeline. - Bump pinned GitHub Action versions across all workflows (checkout v6->v7, setup-uv v8.1.0->v9.0.0, upload-pages-artifact v3->v5, deploy-pages v4->v5). Co-authored-by: Peter Feerick <5500713+pfeerick@users.noreply.github.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 4ec489e commit 75fd2f9

6 files changed

Lines changed: 127 additions & 17 deletions

File tree

.github/workflows/gh-pages.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ jobs:
2929
build:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/checkout@v6
33-
- uses: astral-sh/setup-uv@v8.1.0
32+
- uses: actions/checkout@v7
33+
- uses: astral-sh/setup-uv@v9.0.0
3434
with:
3535
enable-cache: false
3636
- name: Generate site
3737
run: uv run tools/generate_site.py --scripts-json scripts.json --assets-dir ASSETS --output-dir site
3838
- name: Upload Pages artifact
3939
if: github.event_name != 'pull_request'
40-
uses: actions/upload-pages-artifact@v3
40+
uses: actions/upload-pages-artifact@v5
4141
with:
4242
path: ./site
4343
- name: Upload PR preview artifact
@@ -56,4 +56,4 @@ jobs:
5656
url: ${{ steps.deployment.outputs.page_url }}
5757
steps:
5858
- id: deployment
59-
uses: actions/deploy-pages@v4
59+
uses: actions/deploy-pages@v5
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Localize External Images
2+
3+
on:
4+
pull_request:
5+
types: [labeled]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
localize-images:
12+
# Only run when a maintainer applies the trigger label, and only for
13+
# same-repo branches — GITHUB_TOKEN can never push to a fork's branch
14+
# anyway, so skip the attempt rather than fail noisily.
15+
if: |
16+
github.event.label.name == 'localize-images' &&
17+
github.event.pull_request.head.repo.full_name == github.repository
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v7
22+
with:
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
25+
- uses: astral-sh/setup-uv@v9.0.0
26+
with:
27+
enable-cache: false
28+
29+
- name: Configure git identity
30+
run: |
31+
git config user.name "github-actions[bot]"
32+
git config user.email "github-actions[bot]@users.noreply.github.com"
33+
34+
- name: Download and localize external images
35+
run: |
36+
set +e
37+
uv run tools/download_external_images.py 2>&1 | tee /tmp/localize-images-output.txt
38+
exit_code=${PIPESTATUS[0]}
39+
set -e
40+
if [ "$exit_code" -eq 2 ]; then
41+
echo "::error::download_external_images.py failed with a file I/O or argument error — see the log above."
42+
exit 2
43+
fi
44+
if [ "$exit_code" -eq 1 ]; then
45+
echo "::warning::Some images failed to download — see the log above. Any entries that succeeded were still applied."
46+
fi
47+
48+
# Downloaded images are new, untracked files under ASSETS/, not just
49+
# modifications to scripts.json — stage first so `git diff --cached`
50+
# picks those up too, then only commit if something actually changed.
51+
- name: Commit localized images if anything changed
52+
run: |
53+
git add scripts.json ASSETS
54+
if git diff --cached --quiet; then
55+
echo "No image changes to commit."
56+
else
57+
git commit -m "chore: localize external images"
58+
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
59+
fi

.github/workflows/script-submission.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@v6
21+
- uses: actions/checkout@v7
2222

23-
- uses: astral-sh/setup-uv@v8.1.0
23+
- uses: astral-sh/setup-uv@v9.0.0
2424
with:
2525
enable-cache: false
2626

@@ -71,9 +71,10 @@ jobs:
7171
.github/ISSUE_TEMPLATE/update-script.yml
7272
VERB="Add"
7373
if [ "$MODE" = "patch" ]; then VERB="Update"; fi
74+
CLEAN_TITLE=$(echo "$ISSUE_TITLE" | sed -E 's/^\[Lua App (Submission|Update)\] *//')
7475
git commit -m "feat(scripts): ${VERB} script from issue #${ISSUE_NUMBER}
7576
76-
${ISSUE_TITLE}
77+
${CLEAN_TITLE}
7778
7879
Closes #${ISSUE_NUMBER}"
7980
git push origin "$BRANCH"
@@ -94,11 +95,12 @@ jobs:
9495
const mode = process.env.MODE;
9596
9697
const verb = mode === "insert" ? "Add" : "Update";
98+
const cleanTitle = issueTitle.replace(/^\[Lua App (?:Submission|Update)\]\s*/, "");
9799
98100
const pr = await github.rest.pulls.create({
99101
owner: context.repo.owner,
100102
repo: context.repo.repo,
101-
title: `feat(scripts): ${verb} script — ${issueTitle}`,
103+
title: `feat(scripts): ${verb} ${cleanTitle}`,
102104
head: branch,
103105
base: "main",
104106
draft: true,
@@ -107,7 +109,7 @@ jobs:
107109
"",
108110
"### Checklist before merging",
109111
"- [ ] Verify the `scripts.json` diff looks correct",
110-
"- [ ] If any images are still external URLs, run `uv run tools/download_external_images.py` to pull them into `ASSETS/` and update `scripts.json` automatically (use `--dry-run` to preview first)",
112+
"- [ ] If any images are still external URLs, add the `localize-images` label to this PR to pull them into `ASSETS/` and update `scripts.json` automatically (or run `uv run tools/download_external_images.py` locally, using `--dry-run` to preview first)",
111113
"- [ ] Remove draft status when ready to merge",
112114
"",
113115
`Closes #${issueNumber}`

.github/workflows/validate-issue-templates.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ jobs:
4040
if: github.event_name == 'pull_request'
4141
runs-on: ubuntu-latest
4242
steps:
43-
- uses: actions/checkout@v6
44-
- uses: astral-sh/setup-uv@v8.1.0
43+
- uses: actions/checkout@v7
44+
- uses: astral-sh/setup-uv@v9.0.0
4545
with:
4646
enable-cache: false
4747
- name: Run sync script tests
@@ -59,8 +59,8 @@ jobs:
5959
permissions:
6060
contents: write
6161
steps:
62-
- uses: actions/checkout@v6
63-
- uses: astral-sh/setup-uv@v8.1.0
62+
- uses: actions/checkout@v7
63+
- uses: astral-sh/setup-uv@v9.0.0
6464
with:
6565
enable-cache: false
6666
- name: Run sync script tests
@@ -104,8 +104,8 @@ jobs:
104104
# trusted copy of the sync script, never the PR's own version — a
105105
# malicious PR can't smuggle in a modified script for this elevated
106106
# job to execute.
107-
- uses: actions/checkout@v6
108-
- uses: astral-sh/setup-uv@v8.1.0
107+
- uses: actions/checkout@v7
108+
- uses: astral-sh/setup-uv@v9.0.0
109109
with:
110110
enable-cache: false
111111
- name: Fetch PR's scripts.json as data only (never executed)

.github/workflows/validate-scripts-json.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
validate:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v6
21-
- uses: astral-sh/setup-uv@v8.1.0
20+
- uses: actions/checkout@v7
21+
- uses: astral-sh/setup-uv@v9.0.0
2222
with:
2323
enable-cache: false
2424
- name: Validate scripts.json

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contributing
2+
3+
This repo is a gallery of community Lua Apps and Widgets for EdgeTX. [`scripts.json`](scripts.json) is the
4+
single source of content — entries are validated against [`scripts.schema.json`](scripts.schema.json) and
5+
rendered into the [gallery site](https://edgetx.org/lua-scripts/).
6+
7+
## Submitting or updating a gallery entry
8+
9+
You don't need to edit `scripts.json` yourself — open an issue instead:
10+
11+
- [Add a Lua App or Widget to the Gallery](https://github.com/EdgeTX/lua-scripts/issues/new?template=add-script.yml)
12+
- [Update / Correct a Lua App or Widget Entry](https://github.com/EdgeTX/lua-scripts/issues/new?template=update-script.yml)
13+
- [Feedback / Report an Issue](https://github.com/EdgeTX/lua-scripts/issues/new?template=feedback.yml)
14+
15+
Fill in the form fields — name, category, description, info URL, and (optionally) screenshots. Screenshot URLs
16+
can be external links (raw GitHub, Imgur, etc.) or you can drag-and-drop / paste image files directly into the
17+
form and GitHub will host them for you.
18+
19+
## What happens after you submit
20+
21+
1. A maintainer reviews the issue and applies the `add-to-gallery` (new entry) or `update-in-gallery`
22+
(existing entry) label.
23+
2. That label triggers [`script-submission.yml`](.github/workflows/script-submission.yml), which parses the
24+
issue, updates `scripts.json`, validates it, and opens a **draft PR** back to the issue.
25+
3. If the submission included external image URLs, a maintainer applies the `localize-images` label to the
26+
draft PR. This triggers [`localize-images.yml`](.github/workflows/localize-images.yml), which downloads
27+
those images into `ASSETS/<slug>/`, rewrites `scripts.json` to point at the local copies, and pushes the
28+
result back to the PR branch as a commit.
29+
4. Once the diff looks correct, a maintainer removes draft status and merges.
30+
5. Merging to `main` regenerates the gallery site via [`gh-pages.yml`](.github/workflows/gh-pages.yml).
31+
32+
## CI checks
33+
34+
- [`validate-scripts-json.yml`](.github/workflows/validate-scripts-json.yml) validates `scripts.json` against
35+
`scripts.schema.json` on every push/PR that touches it.
36+
- [`validate-issue-templates.yml`](.github/workflows/validate-issue-templates.yml) keeps the tag/category
37+
dropdowns in the issue templates in sync with `scripts.schema.json`, and self-heals same-repo branches
38+
automatically when they drift.
39+
40+
## Running the tooling locally
41+
42+
The scripts under [`tools/`](tools/) are plain Python, run via [`uv`](https://docs.astral.sh/uv/) — no project
43+
setup required beyond having `uv` installed:
44+
45+
```bash
46+
uv run tools/validate_scripts.py --scripts-json scripts.json
47+
uv run tools/download_external_images.py --dry-run # preview image localization
48+
uv run tools/sync_issue_template_options.py --check # check tag/category drift
49+
```

0 commit comments

Comments
 (0)