ci,packaging: enable automated nightly schedule and Stage 2 signer dispatch (#2712)

* ci,packaging: enable automated nightly schedule and Stage 2 signer dispatch

* ci: update actions lockfile for nightly-dispatch.yml
This commit is contained in:
Dylan M. Taylor authored and GitHub committed 2026-11-29 17:00:08 -05:00
1 parent 20f9a0f36d
commit 3598bdcd15
7 files changed
+113 -16

No files matched your search

+3 -1
View File
@@ -83,7 +83,9 @@
}
},
"max_artifact_bytes": 2147483648,
"automatic_signer_actors": [],
"automatic_signer_actors": [
"github-actions[bot]"
],
"platforms": {
"windows-x86_64": {
"unsigned_artifact_name": "nightly-unsigned-windows-x86_64",
+2 -2
View File
@@ -9,8 +9,9 @@ workflows:
'.github/workflows/lockfile.yml':
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/nightly-dispatch.yml': []
'.github/workflows/nightly-macos.yml':
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
- 'actions/checkout@v7.0.1'
- 'actions/upload-artifact@v7.0.2'
- 'step-security/dtolnay-rust-toolchain@v1.0.0'
- 'step-security/harden-runner@v2.23.0'
@@ -20,7 +21,6 @@ workflows:
'.github/workflows/nix.yml': []
'.github/workflows/notify-services.yml': []
'.github/workflows/packaging-lint.yml':
- 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1'
- 'actions/checkout@v7.0.1'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/release.yml':
+71
View File
@@ -0,0 +1,71 @@
name: Dispatch release-ref nightly
# Transport only, never authorization. No checkout, payload parsing or release environment.
on:
workflow_run:
workflows: [FigCraft unsigned nightly]
types: [completed]
branches: [main]
permissions: {}
jobs:
dispatch:
if: >-
github.repository == 'storytold/figcraft' &&
github.event_name == 'workflow_run'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: write
steps:
- name: Dispatch only the exact completed producer run and attempt
shell: python
env:
GH_TOKEN: ${{ github.token }}
run: |
import json
import os
import urllib.request
def require(value, message):
if not value:
raise RuntimeError(message)
# These filters reduce noise; the protected signer-branch validator repeats admission
# against authenticated API metadata and required attestation/quality evidence.
require(os.environ.get('GITHUB_REPOSITORY') == 'storytold/figcraft', 'wrong repository')
require(os.environ.get('GITHUB_EVENT_NAME') == 'workflow_run', 'wrong event')
with open(os.environ['GITHUB_EVENT_PATH'], encoding='utf-8') as stream:
event = json.load(stream)
require(event.get('action') == 'completed', 'producer is not complete')
require(event.get('repository', {}).get('full_name') == 'storytold/figcraft', 'wrong event repository')
producer = event.get('workflow_run', {})
require(producer.get('head_repository', {}).get('full_name') == 'storytold/figcraft', 'foreign producer')
require(producer.get('path') == '.github/workflows/nightly.yml', 'wrong producer path')
require(producer.get('head_branch') == 'main', 'wrong producer branch')
require(producer.get('status') == 'completed' and producer.get('conclusion') == 'success', 'producer did not succeed')
# First scheduled attempt only; reviewed manual/re-run authority belongs to release policy.
require(producer.get('event') == 'schedule', 'not an automatic scheduled producer')
run_id, attempt = producer.get('id'), producer.get('run_attempt')
require(type(run_id) is int and run_id > 0, 'invalid producer run id')
require(type(attempt) is int and attempt == 1, 'invalid automatic producer attempt')
body = json.dumps({'ref': 'refs/heads/nightly-signer', 'inputs': {
'producer_run_id': str(run_id), 'producer_run_attempt': str(attempt)
}}).encode('utf-8')
request = urllib.request.Request(
'https://api.github.com/repos/storytold/figcraft/actions/workflows/nightly-sign.yml/dispatches',
data=body, method='POST', headers={
'Authorization': 'Bearer ' + os.environ['GH_TOKEN'],
'Accept': 'application/vnd.github+json',
'Content-Type': 'application/json',
'X-GitHub-Api-Version': '2022-11-28',
'User-Agent': 'figcraft-nightly-dispatch'
})
class NoRedirect(urllib.request.HTTPRedirectHandler):
def redirect_request(self, req, fp, code, msg, headers, newurl):
raise RuntimeError('dispatch redirects are forbidden')
# One bounded request, no retry: duplicate transport is not publication authority.
with urllib.request.build_opener(NoRedirect()).open(request, timeout=20) as response:
require(response.status == 204, 'dispatch was not accepted')
print('Dispatched producer run/attempt to the release-ref validator; not a signing result.')
+1 -1
View File
@@ -39,7 +39,7 @@ jobs:
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
# The same craft-fonts commit the Nightly producer pins (nightly.yml craft-fonts-ref), so the
+3 -2
View File
@@ -1,8 +1,9 @@
name: FigCraft unsigned nightly
# Enabled for supervised manual runs by the reviewed manual actors only; no schedule yet.
# A later explicit opt-in may add a cadence (and a completion dispatcher with it).
# Automated nightly schedule (02:30 UTC) plus supervised manual runs by the reviewed manual actors.
on:
schedule:
- cron: '30 2 * * *'
workflow_dispatch:
permissions:
+1 -1
View File
@@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: FreeBSD package layout (dry run)
+32 -9
View File
@@ -201,15 +201,21 @@ class TrustedSourcePreparation(unittest.TestCase):
(indicator, expression), = job_conditions(jobs)
self.assertFalse(indicator == ">-" and " ".join(expression.split()) == expected)
def test_no_nightly_schedule_is_registered(self):
for name, event in (("nightly.yml", "workflow_dispatch"),
("nightly-sign.yml", "workflow_dispatch")):
def test_nightly_triggers_match_reviewed_schedule_and_dispatch(self):
expected = (
("nightly.yml", [" schedule:", " workflow_dispatch:"]),
("nightly-sign.yml", [" workflow_dispatch:"]),
("nightly-dispatch.yml", [" workflow_run:"]),
)
for name, expected_triggers in expected:
source = (ROOT / ".github/workflows" / name).read_text()
events = source.split("\non:\n", 1)[1].split("\npermissions:", 1)[0]
triggers = [line for line in events.splitlines() if line.startswith(" ")
and not line.startswith(" ") and line.strip() and not line.lstrip().startswith("#")]
with self.subTest(workflow=name):
self.assertEqual(triggers, [f" {event}:"], "schedule/activation needs explicit review")
self.assertEqual(triggers, expected_triggers, "schedule/activation needs explicit review")
nightly = (ROOT / ".github/workflows/nightly.yml").read_text()
self.assertEqual(re.findall(r"(?m)^ - cron: '([^']+)'$", nightly), ["30 2 * * *"])
def test_signer_serialization_contract_is_enforced(self):
assert_nightly_serialization((ROOT / ".github/workflows/nightly-sign.yml").read_text())
@@ -230,7 +236,7 @@ class TrustedSourcePreparation(unittest.TestCase):
assert_nightly_serialization(source.replace(old, new))
def test_no_cache_actions_or_cache_setup_options_in_app_trusted_closure(self):
for name in ("nightly.yml", "nightly-sign.yml"):
for name in ("nightly.yml", "nightly-sign.yml", "nightly-dispatch.yml"):
source = (ROOT / ".github/workflows" / name).read_text()
executable = "\n".join(line for line in source.splitlines()
if not line.lstrip().startswith("#"))
@@ -328,6 +334,7 @@ class NightlyEnabledCallers(unittest.TestCase):
"github.event_name == 'workflow_dispatch')",
"nightly-sign.yml": "github.repository == 'storytold/figcraft' && github.event_name == 'workflow_dispatch' && "
"github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'",
"nightly-dispatch.yml": "github.repository == 'storytold/figcraft' && github.event_name == 'workflow_run'",
}
def test_enabled_jobs_keep_exact_context_guards(self):
@@ -344,7 +351,8 @@ class NightlyEnabledCallers(unittest.TestCase):
source = (ROOT / ".github/workflows/nightly.yml").read_text()
policy = json.loads(INSTALLED_POLICY.read_text())
self.assertEqual(reviewed_manual_actors(source, policy), RELEASE_MANAGERS)
self.assertEqual(policy["automatic_signer_actors"], [], "no automatic signer without a schedule")
self.assertEqual(policy["automatic_signer_actors"], ["github-actions[bot]"],
"automatic signer is limited to github-actions[bot]")
def test_an_actor_outside_the_release_managers_is_refused(self):
source = (ROOT / ".github/workflows/nightly.yml").read_text()
@@ -770,9 +778,24 @@ class NightlySignerBranchTrustClosure(unittest.TestCase):
self.assertIn("github.ref == 'refs/heads/" + SIGNER_BRANCH + "'", guard)
self.assertNotIn("refs/heads/release", sign, "the signer no longer runs on the stable branch")
self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), ["figcraft"], "the shared signer needs the reviewed registry app")
# This app ships no completion dispatcher yet: that workflow forwards scheduled producers
# only, and no schedule is approved. Adding it is part of a reviewed cadence change.
self.assertFalse(DISPATCHER.exists(), "a completion dispatcher needs its own reviewed activation")
self.assertTrue(DISPATCHER.exists(), "automated scheduled cadence requires the completion dispatcher")
dispatcher = DISPATCHER.read_text()
nightly_name = re.findall(r"(?m)^name: (.+)$", (ROOT / ".github/workflows/nightly.yml").read_text())
self.assertEqual(nightly_name, ["FigCraft unsigned nightly"])
self.assertIn(f" workflows: [{nightly_name[0]}]\n", dispatcher)
self.assertIn(" types: [completed]\n", dispatcher)
self.assertIn(" branches: [main]\n", dispatcher)
self.assertIn("\npermissions: {}\n", dispatcher)
self.assertNotIn("false &&", dispatcher, "dispatcher must be active once automated schedule is enabled")
self.assertNotRegex(dispatcher, r"(?im)^\s*(?:uses|environment|secrets):")
scripts = inline_scripts(DISPATCHER)
self.assertEqual(len(scripts), 1)
compile(scripts[0], str(DISPATCHER), "exec")
self.assertIn("'ref': 'refs/heads/" + SIGNER_BRANCH + "'", scripts[0])
self.assertIn("https://api.github.com/repos/storytold/figcraft/actions/workflows/nightly-sign.yml/dispatches",
scripts[0])
self.assertIn("producer.get('event') == 'schedule'", scripts[0])
self.assertIn("attempt == 1", scripts[0])
self.assertEqual(json.loads(INSTALLED_POLICY.read_text())["release_branch"], SIGNER_BRANCH)
self.assertFalse((ROOT / "docs/nightly-signing-policy.example.json").exists(),
"a policy example must then name the signer branch")