mirror of
https://git.openapi.site/https://github.com/desirecore/market.git
synced 2026-12-05 10:19:23 +08:00
fix(ci): switch pull_request_target workflows to pull_request (#432)
GitHub now restricts `pull_request_target` on public repositories by default, causing `i18n Auto-Translate` (required `translate` check) and `Auto-request Copilot review` to fail immediately with `startup_failure`. ### Changes - **`.github/workflows/i18n-translate.yml`**: - Switch trigger from `pull_request_target` to `pull_request`. - Explicitly check out `github.base_ref` on `pull_request` and keep the data-only overlay model (`skills/`, `manifest.json`, `categories.json`, symlink removal) so untrusted PR scripts are never executed. - Gate auto-translate, push, PR comment, and failure-label steps to same-repo PRs (`github.event.pull_request.head.repo.full_name == github.repository`) so fork PRs (which receive read-only tokens under `pull_request`) run `translate.py --check` and fail cleanly with local translation instructions instead of crashing with 403. - **`.github/workflows/auto-request-copilot-review.yml`**: - Switch trigger from `pull_request_target` to `pull_request` (keeping `opened`, `reopened`, `ready_for_review`). - Guard the `request` job to non-draft same-repo PRs so fork PRs do not fail with 403. - **`scripts/catalog/test_review_workflow.py`**: - Update assertions to require `pull_request` (and reject `pull_request_target`) plus verify the non-draft & same-repo job guard while preserving all no-checkout/no-code-execution assertions. ### Verification - `uv run --offline --quiet scripts/catalog/test_review_workflow.py` — passed - `pytest scripts/catalog/test_tracked_updates.py -q` — 64 passed - `uv run --offline --quiet scripts/i18n/validate-i18n.py` — passed - `uv run --offline --quiet scripts/catalog/validate_catalog_metadata.py --require-complete` — 0 errors
This commit is contained in:
1 parent
871a57074a
commit
f6d1eccf70
3 files changed
+40
-27
No files matched your search
@@ -14,9 +14,12 @@ class ReviewWorkflowTests(unittest.TestCase):
|
||||
path = Path(__file__).resolve().parents[2] / '.github/workflows/auto-request-copilot-review.yml'
|
||||
text = path.read_text()
|
||||
workflow = yaml.load(text, Loader=yaml.BaseLoader)
|
||||
self.assertIn('pull_request_target', workflow['on'])
|
||||
self.assertNotIn('pull_request', workflow['on'])
|
||||
self.assertIn('pull_request', workflow['on'])
|
||||
self.assertNotIn('pull_request_target', workflow['on'])
|
||||
self.assertEqual(workflow['permissions']['pull-requests'], 'write')
|
||||
job_if = workflow['jobs']['request']['if']
|
||||
self.assertIn('github.event.pull_request.draft == false', job_if)
|
||||
self.assertIn('github.event.pull_request.head.repo.full_name == github.repository', job_if)
|
||||
for step in workflow['jobs']['request']['steps']:
|
||||
self.assertNotIn('uses', step)
|
||||
script = step.get('run', '')
|
||||
|
||||
Reference in new issue
Block a user