Repository navigation
Add approve-publication workflow - #124
Merged
Merged
Conversation
Runs a publication approval to completion on a runner by driving the nemar CLI loop, so the web Approve button can hand off to it. Inputs are validated and the environment picks both API host and credential from a fixed map. The job reads the request's final state back from the API and fails unless it is published, because the CLI exits 0 on a failed approval. Tested: actionlint with shellcheck, yamllint, and the validate, preflight, approve, and verify steps run locally against hostile input, a stub API, and a fake CLI. Not run on a real runner.
3 of 4 tasks
Refuse to approve unless the dispatched request is still the newest active one for the dataset, so a delayed run cannot approve a re-request nobody clicked. Accept xx exemplar ids on dev only. Install bun and the CLI before the admin key is selected, and log in from the environment so the key stays off the command line. Default manual runs to dev, point the CLI at the same host as curl in both environments, time-box the approve step so the verify step always runs, name the trigger in the summary, branch the final hint on the request status, and document the S3 lock resume limit. Tested: actionlint with shellcheck; the validate and preflight scripts run against hostile inputs and a local stand-in API.
A click-time resume flag goes stale when a second dispatch follows a first that already ran steps, and a fresh run restarts the step list. The preflight now forces --resume when the newest active request is approving. It also fails when the dispatched request carries no claiming admin, since the approval would then be recorded under the workflow's key. Tested: actionlint; the preflight script against a local stand-in API (claimed, unclaimed, older backend, approving, re-request, manual).
This was referenced Oct 1, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
approve-publication.yml, the executor for web approvals. When an admin clicks Approve on nemar.org, the backend will send onerepository_dispatchhere; this workflow runsnemar admin publish approveto completion on a runner.Approval is not a single request. After the DOI is published, the S3 Object Lock step works in batches of 100 objects that the caller must keep requesting, and the
nemarCLI is the caller that loops, retries, and resumes. Running that loop in a Cloudflare Worker would cost too much, so an executor drives it. This is one executor; a terminal running the CLI is the other, and the backend route stays the contract.Trigger and payload
repository_dispatchwithevent_type: approve-publication, orworkflow_dispatch(same inputs, minusrequest_id; manual runs default todev).{ "dataset_id": "nm000290", "request_id": 835, "resume": false, "environment": "production" }dataset_id:nmoronplus six digits; ondevalsoxxplus six digits (the exemplar fleet). Anything else fails the job.environment:productionordev. Required for a dispatch; a missing value fails closed rather than defaulting to production.resume: true runs--resume(skips completed steps). Absent means false.request_id: the request the admin clicked. The run refuses to approve unless it is still the newest active request for the dataset (see Preflight).How it works
env:and is checked in one step that writes the validated values toGITHUB_ENV. No${{ }}is interpolated into any script, and a rejected value is never echoed.productionishttps://api.nemar.org,devishttps://api-test.nemar.org). No URL comes from the payload. There is one credentials step per environment, so a missing dev secret fails instead of falling back to the production key. The CLI is pointed at the same host as curl (TEST_API_URL) in both environments.request_idmust still be the newest active request (requested, approving or blocked) for the dataset, becausenemar admin publish approveacts on the newest one when it runs. Without this, a run that waited in a queue while an admin denied the request and the owner asked again would approve a request no admin saw. The request must also carry the admin who clicked (the backend records it on the request), since otherwise the approval would be recorded under the workflow's key. The same step decides resume from the request's real state: if the newest active request is already approving, the run resumes it, because the click-time flag can be stale and a fresh run restarts the step list. Manual runs have no request id and skip the request checks.nemar auth login --yes(the key comes from the environment, not the command line), thennemar admin publish approve <id> --yes [--resume]in a step capped at 340 minutes.--skip-ci-checkis never passed.GET /datasets/<id>/publish/statusand fails the job unless the status ispublished, with a hint that depends on where the request stands. Server text goes only to the job summary file, with backticks removed. The summary names who triggered the run.permissions: {},timeout-minutes: 350(same as the import copy job), and a concurrency group per environment and dataset withcancel-in-progress: false.Findings worth knowing
Testing
xxon production, newline and command-substitution payloads, wrong case, unknown environment) and a local stand-in for the list route (request still newest and claimed, not claimed, older backend, approving forces resume, denied then re-requested, newer blocked request, no active request, manual run, wrong key, unreachable host).workflow_dispatchwithenvironment=devfor a dataset that has no active request exercises install, login, preflight and verify without changing anything.Secrets
NEMAR_ADMIN_API_KEYonboard-openneuro.ymlin this repo already uses it. Value not read.NEMAR_ADMIN_API_KEY_DEVTEST_ADMIN_API_KEY) lives on that repo, not this one. It must be created onnemarDatasets/.githubbeforeenvironment=devworks. Production does not need it.Deploy order
Merge this before the backend dispatches in production. A dispatch with no workflow does nothing, so the page would show the approval as queued forever. The backend route and migration go to
devfirst, then production, then the website.Testing
actionlint(with shellcheck) passes, and fails on a deliberately broken copyyamllintpassesAPI_URL, path traversal, wrong case, unknown environment,resume: yes): all rejected, nothing writtenpublished, and keeps hostile server text out of the logactis not installed here, and a dispatch would run a real approvalNEMAR_ADMIN_API_KEYis an admin key on production, that the dev secret exists, and that the dev Worker's dispatch reaches this repo. The publishednemar-cli(0.10.11) matches the source I read for--yesandTEST_API_URL.Notes
https://api-test.nemar.orgfor dev. nemar-cli's own test workflows usehttps://nemar-api-dev.sccn-org.workers.dev. If those are different deployments, the dev URL in the validation step needs to match whichever the dev Worker serves.