Skip to content

Debloat your Android TV, install apps, browse and transfer files on it, all from your phone. Just 3 MB, no tracking, no root, no PC.

Data opens a pull request with the signed index

tellyscope-agentac7a4192543b
diff --git a/.github/workflows/data.yml b/.github/workflows/data.yml
index 5031185..cbf1817 100644
--- a/.github/workflows/data.yml
+++ b/.github/workflows/data.yml
@@ -1,7 +1,9 @@
name: Data
# data/ is downloaded by every installed app straight from dev (alpha) and main, so it may only reach them
-# signed. Pull requests into dev are signed after merge, by the sign job below: nobody signs locally.
+# signed. Pull requests into dev are signed after merge, by the sign job below, which opens a pull request
+# from data/sign with the signed index: nobody signs locally. Run this workflow by hand on data/sign to
+# check that pull request, since one opened by the workflow triggers no checks of its own.
on:
pull_request:
branches: [dev, main]
@@ -9,6 +11,7 @@ on:
push:
branches: [main, dev]
paths: ["data/**", "tools/data.py", "tools/test_data.py", "tools/data-keys/**", ".github/workflows/data.yml"]
+ workflow_dispatch:
permissions:
contents: read
@@ -16,7 +19,7 @@ permissions:
jobs:
check:
name: data/ index and signature
- if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
+ if: github.event_name != 'push' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
@@ -24,6 +27,7 @@ jobs:
persist-credentials: false
- name: Tests
run: python3 -m unittest discover -s tools -p 'test_data.py' -v
+ # A run by hand has no base, so it checks the signature too.
- name: data/index.json is fresh, and signed unless this pull request goes into dev
env:
BASE: ${{ github.base_ref }}
@@ -47,7 +51,8 @@ jobs:
python3 tools/data.py index
if python3 tools/data.py check; then echo needed=false; else echo needed=true; fi >> "$GITHUB_OUTPUT"
- # Waits for the data-signing environment's reviewer, so it runs only when the index really changed.
+ # Waits for the data-signing environment's reviewer, so it runs only when the index really changed. dev
+ # takes changes only through pull requests, so the signed index goes to data/sign and a pull request.
sign:
name: Sign data/index.json
needs: needs-sign
@@ -56,6 +61,7 @@ jobs:
environment: data-signing
permissions:
contents: write
+ pull-requests: write
concurrency:
group: data-signing
cancel-in-progress: false
@@ -76,11 +82,27 @@ jobs:
- name: Delete the key
if: always()
run: rm -f "$RUNNER_TEMP/data-signing.pem"
- - name: Check, commit and push
+ - name: Check, commit, push data/sign and open its pull request
+ env:
+ GH_TOKEN: ${{ github.token }}
run: |
python3 tools/data.py check
git diff --quiet -- data/index.json && exit 0
+ version=$(jq -r .version data/index.json) base=$(git rev-parse --short HEAD)
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- git commit -q -m "data/index.json: sign version $(jq -r .version data/index.json)" -- data/index.json
- git push origin HEAD:dev
+ git switch -q -C data/sign
+ git commit -q -m "data/index.json: sign version $version" -- data/index.json
+ git push -q --force origin HEAD:refs/heads/data/sign
+ body=$(printf '%s\n' \
+ "Signed \`data/index.json\` version $version, from \`dev\` at $base." \
+ "" \
+ "\`python3 tools/data.py check\` passed in [the signing run]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." \
+ "" \
+ "Before merging, run the \`Data\` workflow on \`data/sign\` (Actions → Data → Run workflow): this pull request triggers no checks itself.")
+ pr=$(gh pr list --head data/sign --base dev --state open --json number --jq '.[].number')
+ if [ -n "$pr" ]; then
+ gh pr edit "$pr" --title "data/index.json: sign version $version" --body "$body"
+ else
+ gh pr create --head data/sign --base dev --title "data/index.json: sign version $version" --body "$body"
+ fi
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 51095a6..65f9ed0 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -66,9 +66,13 @@ index:
also what `Data` checks on a pull request into `dev`.
2. After the merge, `Data`'s `needs-sign` job runs `index` and `check` without secrets. When the index
needs a signature, the `sign` job waits for the maintainer's approval in the `data-signing`
- environment, signs with its `DATA_SIGNING_KEY` secret, and commits the signed `data/index.json` to
- `dev`. Alpha builds read that.
-3. The `dev` → `main` release carries the signed index; `Data` runs the full `check` on pull requests
+ environment, signs with its `DATA_SIGNING_KEY` secret, force-pushes the signed `data/index.json` to
+ the `data/sign` branch, and opens a pull request from it into `dev` (or updates the open one).
+3. The maintainer runs `Data` by hand on `data/sign` (Actions → Data → Run workflow, no secrets): a
+ pull request opened by a workflow triggers no checks itself, and a run by hand checks the signature
+ too. Once it passes, merge the pull request. Alpha builds read the signed index from `dev`, and the
+ merge doesn't ask for another signature, because the index on `dev` is now signed.
+4. The `dev` → `main` release carries the signed index; `Data` runs the full `check` on pull requests
into `main` and on `main` itself.
Signing only after merge matters: once a signed `data/index.json` is on GitHub it stays fetchable by its