diff --git a/.github/workflows/notebook-test.yml b/.github/workflows/notebook-test.yml index 50bab0162d..094d16ac0d 100644 --- a/.github/workflows/notebook-test.yml +++ b/.github/workflows/notebook-test.yml @@ -68,9 +68,24 @@ jobs: args = ["tox", "--", "--write"] if changed_notebooks and not changed_config: args.extend(changed_notebooks.split("\n")) - if os.environ["PR_REPOSITORY"] != os.environ["GITHUB_REPOSITORY"]: - args.append("--is-fork") - subprocess.run(args, check=True) + try: + subprocess.run(args, check=True) + except Exception as err: + if os.environ["PR_REPOSITORY"] != os.environ["GITHUB_REPOSITORY"]: + raise SystemExit( + "We can't run this test on pull requests from forks." + "\n\n" + "If you have write access to Qiskit/documentation, push to a new " + "branch there and make your pull request from that branch instead." + "\n\n" + "If you don't have write access, you must test out the notebook " + "locally using the instructions in " + "https://github.com/Qiskit/documentation#execute-notebooks." + "When this PR is approved, a maintainer will merge it to a new " + "branch in Qiskit/documentation, then make a PR from that branch " + "into main so it can pass CI." + ) from err + raise err - name: Detect changed notebooks id: changed-notebooks