@eduardo191labs/opencode-actions 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +259 -5
- package/action.yml +71 -9
- package/dist/actions.d.ts +337 -65
- package/dist/actions.js +271 -27
- package/dist/app-auth.d.ts +70 -0
- package/dist/app-auth.js +137 -0
- package/dist/cli.js +35 -4
- package/dist/commands.d.ts +3 -1
- package/dist/commands.js +59 -19
- package/dist/compile.js +15 -11
- package/dist/config.d.ts +5 -1
- package/dist/config.js +1 -1
- package/dist/detect.d.ts +37 -4
- package/dist/detect.js +103 -78
- package/dist/format.d.ts +4 -1
- package/dist/format.js +5 -2
- package/dist/git.d.ts +16 -0
- package/dist/git.js +23 -1
- package/dist/github.d.ts +9 -1
- package/dist/implement.d.ts +116 -0
- package/dist/implement.js +192 -0
- package/dist/install.js +195 -20
- package/dist/review-thread.d.ts +63 -0
- package/dist/review-thread.js +70 -0
- package/dist/runner.js +1 -1
- package/dist/signals.d.ts +134 -0
- package/dist/signals.js +117 -0
- package/dist/summary.js +2 -0
- package/package.json +4 -2
- package/scripts/check-marketplace.js +111 -0
- package/scripts/install-opencode.sh +74 -0
package/README.md
CHANGED
|
@@ -17,6 +17,8 @@ click; the bot never pushes during a review.
|
|
|
17
17
|
| Capability | Trigger | What happens |
|
|
18
18
|
|---|---|---|
|
|
19
19
|
| **PR review** | `pull_request` opened / updated / ready | Inline comments with `suggestion` blocks. Never edits, approves or pushes by default. |
|
|
20
|
+
| **Review replies** | comment on a diff line | Answered in its own thread with the hunk GitHub sends. `/bot fix` commits to the head branch. |
|
|
21
|
+
| **Commit review** | `push` to a tracked branch | Reviews the change and posts it as a commit comment. |
|
|
20
22
|
| **Issue triage** | `issues` opened | Severity, labels, a reproduction verdict and a plan. |
|
|
21
23
|
| **Issue answer** | `/bot answer` | A grounded answer citing `file:line`. |
|
|
22
24
|
| **Issue implementation** | `/bot implement` | Makes the change, commits it, opens a PR. |
|
|
@@ -245,8 +247,18 @@ When `config-repo` is **private**, pass `config-token` with a token that can rea
|
|
|
245
247
|
|
|
246
248
|
The installer detects the stack in each repository (Node, Rust, Go, Python, JVM,
|
|
247
249
|
Ruby, PHP, C/C++, .NET, Swift, Dart), skips archived, disabled and forked ones, and
|
|
248
|
-
writes
|
|
249
|
-
|
|
250
|
+
writes the workflows that only touch files it owns. Re-running is safe: a workflow
|
|
251
|
+
file without the bot marker is never overwritten.
|
|
252
|
+
|
|
253
|
+
**It installs itself.** The `Install` workflow runs every six hours with `--auto`,
|
|
254
|
+
which treats a repository that already has the bot as skipped. A new repository is
|
|
255
|
+
picked up on the next pass, and one where the bot was removed is repaired. No person
|
|
256
|
+
runs anything.
|
|
257
|
+
|
|
258
|
+
With the GitHub App configured (next section) no personal token is involved. Without
|
|
259
|
+
it, the workflow falls back to `OPENCODE_INSTALL_TOKEN`, a fine-grained token with
|
|
260
|
+
**Administration: write** on the target repositories; `GITHUB_TOKEN` cannot install
|
|
261
|
+
into other repositories.
|
|
250
262
|
|
|
251
263
|
```bash
|
|
252
264
|
# Preview
|
|
@@ -275,9 +287,173 @@ on:
|
|
|
275
287
|
dry_run: { type: boolean, default: true }
|
|
276
288
|
```
|
|
277
289
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
290
|
+
The workflow needs `OPENCODE_APP_ID` and `OPENCODE_APP_PRIVATE_KEY`, or
|
|
291
|
+
`OPENCODE_INSTALL_TOKEN` as a fallback.
|
|
292
|
+
|
|
293
|
+
### What triggers an install
|
|
294
|
+
|
|
295
|
+
There is no schedule. Every run is caused by GitHub saying something changed:
|
|
296
|
+
|
|
297
|
+
| Event | When it happens |
|
|
298
|
+
|---|---|
|
|
299
|
+
| `installation` | the app was installed |
|
|
300
|
+
| `installation_repositories` | a repository was granted to the installation |
|
|
301
|
+
| `repository` | a repository was created, forked, made public, renamed or transferred |
|
|
302
|
+
| `issues` | an issue was opened |
|
|
303
|
+
| `issue_comment` | a command or `@mention` was posted |
|
|
304
|
+
| `pull_request` | a pull request opened, synchronised or became ready |
|
|
305
|
+
| `pull_request_review_comment` | a comment on a diff line |
|
|
306
|
+
| `workflow_run` | a workflow finished, for the autofix |
|
|
307
|
+
|
|
308
|
+
`installation` and `installation_repositories` are lifecycle events: GitHub
|
|
309
|
+
delivers them to every app and rejects them inside a manifest's
|
|
310
|
+
`default_events`, so they are not listed and still arrive.
|
|
311
|
+
|
|
312
|
+
**Everything else has to be subscribed, once, by hand.** A GitHub App receives exactly the
|
|
313
|
+
events listed under *Subscribe to events*, with no exceptions — an app with an
|
|
314
|
+
empty list only ever hears about installations, `check_suite` and pings. The API
|
|
315
|
+
cannot change that list either: `PATCH /app` returns 404 for permissions and
|
|
316
|
+
events, which is why the broker and the native workflow trigger both exist. Set
|
|
317
|
+
them in the app's settings, *Permissions & events*:
|
|
318
|
+
|
|
319
|
+
https://github.com/settings/apps/opencode-actions-bot-new/permissions
|
|
320
|
+
|
|
321
|
+
Tick these six under *Subscribe to events*, then **Save changes**:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
Issues Issue comment
|
|
325
|
+
Pull request Pull request review
|
|
326
|
+
Pull request review comment Workflow run
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
`PATCH /app` answers 404 for events, so this is the one step the API cannot do.
|
|
330
|
+
Without it the bot still works through each repository's own workflow trigger,
|
|
331
|
+
but the Cloudflare broker never sees an event and cannot skip anything.
|
|
332
|
+
|
|
333
|
+
**Forks are installed like any other repository.** A fork gets pull requests and
|
|
334
|
+
issues, so skipping it left the bot out of exactly where a contributor works.
|
|
335
|
+
`--exclude-forks` opts out. Archived and disabled repositories are still skipped,
|
|
336
|
+
because nothing happens in them.
|
|
337
|
+
|
|
338
|
+
The only repository the installer skips by default is the configuration one,
|
|
339
|
+
which is passed to `--exclude`.
|
|
340
|
+
|
|
341
|
+
### The webhook worker
|
|
342
|
+
|
|
343
|
+
`webhook/worker.js` runs on Cloudflare Workers: free tier, no dependencies, no
|
|
344
|
+
build step. It verifies `X-Hub-Signature-256` before parsing a byte, then asks the
|
|
345
|
+
`Install` workflow to run.
|
|
346
|
+
|
|
347
|
+
Deployment is automatic. Pushing anything under `webhook/` triggers
|
|
348
|
+
`.github/workflows/webhook.yml`, which tests the worker, deploys it, and checks
|
|
349
|
+
that a signed ping is accepted and a forged one refused. It needs two repository
|
|
350
|
+
secrets:
|
|
351
|
+
|
|
352
|
+
| Secret | Purpose |
|
|
353
|
+
|---|---|
|
|
354
|
+
| `CLOUDFLARE_API_TOKEN` | Workers Scripts: Edit |
|
|
355
|
+
| `CLOUDFLARE_ACCOUNT_ID` | the account id from the dashboard |
|
|
356
|
+
|
|
357
|
+
The worker's own secrets are set once and survive redeploys:
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
npx wrangler secret put WEBHOOK_SECRET --config wrangler.toml
|
|
361
|
+
npx wrangler secret put APP_PRIVATE_KEY --config wrangler.toml
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
The app's webhook is configured from the manifest at creation, so there is
|
|
365
|
+
nothing to paste. `scripts/wire-webhook.js` repairs a mismatch between the two:
|
|
366
|
+
it writes the worker's secrets and `PATCH /app/hook/config` in one step, because
|
|
367
|
+
a deploy that rewrites `WEBHOOK_SECRET` silently breaks every delivery.
|
|
368
|
+
|
|
369
|
+
What happens after a repository is created or forked:
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
GitHub ── webhook ──▶ Worker ── verify HMAC ──▶ repository_dispatch(install-requested)
|
|
373
|
+
│
|
|
374
|
+
▼
|
|
375
|
+
Install workflow → discover → write workflows
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
The worker never writes to a repository. It verifies the signature, mints an
|
|
379
|
+
installation token for the one repository it needs, and asks the `Install`
|
|
380
|
+
workflow to run. The installer stays the only thing that knows how to write, so
|
|
381
|
+
there is one implementation and not two.
|
|
382
|
+
|
|
383
|
+
Why a worker at all: Actions cannot react to "a repository exists now" in another
|
|
384
|
+
repository, and a schedule is both slow and wasteful. The six-hour sweep stays as
|
|
385
|
+
a safety net for what a webhook cannot see, such as a workflow deleted by hand.
|
|
386
|
+
|
|
387
|
+
The worker rejects anything whose `X-Hub-Signature-256` does not match, before
|
|
388
|
+
parsing a byte of the body, and ignores every event except those two.
|
|
389
|
+
|
|
390
|
+
### A GitHub App, so new repositories are covered on their own
|
|
391
|
+
|
|
392
|
+
The installer can act as a **GitHub App** instead of a personal token. That changes
|
|
393
|
+
three things worth understanding:
|
|
394
|
+
|
|
395
|
+
| | `GITHUB_TOKEN` / PAT | GitHub App installation token |
|
|
396
|
+
|---|---|---|
|
|
397
|
+
| Scope | one repository (or everything a PAT can reach) | only the repositories the owner picked |
|
|
398
|
+
| Lifetime | the workflow run / until the PAT expires | one hour, minted per run |
|
|
399
|
+
| New repositories | never found | covered as soon as the installation covers the account |
|
|
400
|
+
| Writing workflows and secrets | needs an admin PAT | granted by the manifest, per permission |
|
|
401
|
+
|
|
402
|
+
Create the app once:
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
node scripts/create-app.js --owner <you> --name opencode-actions-bot
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
It opens one page, GitHub asks you to confirm, and the app id and private key are
|
|
409
|
+
written as `OPENCODE_APP_ID` and `OPENCODE_APP_PRIVATE_KEY`. Then install it:
|
|
410
|
+
|
|
411
|
+
<https://github.com/apps/opencode-actions-bot/installations/new>
|
|
412
|
+
|
|
413
|
+
Pick the account and **All repositories** if new repositories should be covered
|
|
414
|
+
automatically, or a selection if the bot should never touch the rest.
|
|
415
|
+
|
|
416
|
+
The manifest in `github-app-manifest.json` requests what the bot uses, nothing more:
|
|
417
|
+
|
|
418
|
+
```json
|
|
419
|
+
"contents": "write", "pull_requests": "write", "issues": "write",
|
|
420
|
+
"workflows": "write", "secrets": "write", "administration": "write",
|
|
421
|
+
"checks": "write", "statuses": "write", "actions": "write",
|
|
422
|
+
"environments": "write", "deployments": "write", "discussions": "write",
|
|
423
|
+
"packages": "write", "pages": "write", "repository_projects": "write",
|
|
424
|
+
"security_events": "write", "metadata": "read",
|
|
425
|
+
"secret_scanning_alerts": "read", "vulnerability_alerts": "read"
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
What each one buys:
|
|
429
|
+
|
|
430
|
+
| Permission | Why |
|
|
431
|
+
|---|---|
|
|
432
|
+
| `contents`, `pull_requests`, `issues` | commit, open and merge PRs, comment, triage |
|
|
433
|
+
| `workflows` | the installer commits the five workflow files |
|
|
434
|
+
| `secrets` | the installer writes `FREEPI_JWT` and the app credentials per repository |
|
|
435
|
+
| `administration` | default workflow permissions and repository settings |
|
|
436
|
+
| `checks`, `statuses` | report review results on the commit |
|
|
437
|
+
| `actions` | inspect failing runs for autofix |
|
|
438
|
+
| `environments`, `deployments` | deploy-related commands |
|
|
439
|
+
| `discussions`, `packages`, `pages`, `repository_projects` | the wider command surface |
|
|
440
|
+
| `security_events`, `secret_scanning_alerts`, `vulnerability_alerts` | read-only security context |
|
|
441
|
+
| `metadata` | mandatory for every app |
|
|
442
|
+
|
|
443
|
+
> Changing permissions on an existing app has **no API**: `PATCH /app` answers
|
|
444
|
+
> `404`. Either edit them in the app settings, or create the app again from the
|
|
445
|
+
> updated manifest with
|
|
446
|
+
> `node scripts/create-app.js --name <name>`, which is what the manifest is for.
|
|
447
|
+
|
|
448
|
+
At run time the CLI exchanges the app JWT for an installation token for the
|
|
449
|
+
repository in the event, sets it as `GITHUB_TOKEN` (so `git push` keeps working)
|
|
450
|
+
and proceeds exactly as before. If the app is not installed on a repository, the
|
|
451
|
+
run fails with the install URL instead of writing anything.
|
|
452
|
+
|
|
453
|
+
The `Install` workflow uses the same credentials: discovery lists
|
|
454
|
+
`/installation/repositories`, which includes a repository created seconds earlier,
|
|
455
|
+
so **a new repository is picked up by the next scheduled pass with nobody doing
|
|
456
|
+
anything**. The schedule is every six hours.
|
|
281
457
|
|
|
282
458
|
### Detecting a repository
|
|
283
459
|
|
|
@@ -307,6 +483,84 @@ opencode-actions --mode capabilities # what the bot may do on GitHub
|
|
|
307
483
|
| `/bot close` / `/bot reopen` | Change issue or PR state. |
|
|
308
484
|
| `/bot help` | List commands. |
|
|
309
485
|
|
|
486
|
+
The bot answers to three shapes, and a bare mention counts:
|
|
487
|
+
|
|
488
|
+
| You write | The bot does |
|
|
489
|
+
|---|---|
|
|
490
|
+
| `/bot review` | runs the `review` command |
|
|
491
|
+
| `@opencode review` | the same |
|
|
492
|
+
| `@opencode how does the retry loop work?` | `answer` — a mention with no keyword is a question |
|
|
493
|
+
| `@opencode-actions-bot fix the null check` | the app slug works too, because that is what autocomplete inserts |
|
|
494
|
+
|
|
495
|
+
Names are configurable: `bot.name` sets the primary mention and `bot.aliases`
|
|
496
|
+
adds more, so `@bot` can coexist with the long slug. A mention inside an email
|
|
497
|
+
address or a code fence is ignored.
|
|
498
|
+
|
|
499
|
+
Commands also work in a **line comment on the diff**: GitHub sends the file, the line
|
|
500
|
+
and the hunk, so the answer is posted in that same thread. A plain comment there is
|
|
501
|
+
ignored unless the bot is mentioned, and `/bot fix` commits the change to the head
|
|
502
|
+
branch instead of replying with a diff.
|
|
503
|
+
|
|
504
|
+
## Events
|
|
505
|
+
|
|
506
|
+
Each event is handled by its own workflow, so a repository only pays for the ones it
|
|
507
|
+
installs.
|
|
508
|
+
|
|
509
|
+
| Event | Handler | Installed as |
|
|
510
|
+
|---|---|---|
|
|
511
|
+
| `pull_request` | review with inline suggestions | `opencode-review.yml` |
|
|
512
|
+
| `pull_request_review_comment` | in-thread reply, optional fix | `opencode-comments.yml` |
|
|
513
|
+
| `issue_comment` | `/bot` commands | `opencode-commands.yml` |
|
|
514
|
+
| `issues` | triage | `opencode-issues.yml` |
|
|
515
|
+
| `push` | commit review | `opencode-commits.yml` |
|
|
516
|
+
| `workflow_run` | autofix a failing run | added on demand |
|
|
517
|
+
|
|
518
|
+
## GitHub Marketplace
|
|
519
|
+
|
|
520
|
+
The Marketplace checkbox has **no API**: GitHub only offers it in the release form,
|
|
521
|
+
and the listing is a property of the first release of each major line. The `Marketplace`
|
|
522
|
+
workflow therefore automates everything around it:
|
|
523
|
+
|
|
524
|
+
1. verifies the public repository, the single root `action.yml`, the metadata rules and
|
|
525
|
+
the existence of the major tag;
|
|
526
|
+
2. fetches the public listing page to decide whether the action is already listed;
|
|
527
|
+
3. opens a tracking issue with the exact click-path when it is not.
|
|
528
|
+
|
|
529
|
+
`scripts/check-marketplace.js` enforces the rules that only surface at publish time:
|
|
530
|
+
|
|
531
|
+
| Rule | Check |
|
|
532
|
+
|---|---|
|
|
533
|
+
| `name` present, ≤ 65 characters, not reserved | ✓ |
|
|
534
|
+
| `description` < 125 characters | ✓ |
|
|
535
|
+
| `branding.icon` is a Feather icon name | ✓ |
|
|
536
|
+
| `branding.color` ∈ 8 accepted values | ✓ |
|
|
537
|
+
| public repository, one root metadata file | ✓ |
|
|
538
|
+
| global name uniqueness | reported, cannot be checked offline |
|
|
539
|
+
|
|
540
|
+
To list the action: open the release for the major tag → **Edit** → tick
|
|
541
|
+
**Publish this Action to the GitHub Marketplace** → accept the Developer Agreement if
|
|
542
|
+
prompted → choose a category → **Update release**. Later releases in that major line
|
|
543
|
+
update the listing automatically.
|
|
544
|
+
|
|
545
|
+
## Release process
|
|
546
|
+
|
|
547
|
+
Nothing is built or published from a developer machine. A release is a tag:
|
|
548
|
+
|
|
549
|
+
```bash
|
|
550
|
+
git tag -a v0.1.2 -m "opencode-actions 0.1.2"
|
|
551
|
+
git push origin v0.1.2
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
The `Release` workflow then:
|
|
555
|
+
|
|
556
|
+
1. builds and runs the tests;
|
|
557
|
+
2. fails if the committed JSON schema differs from the generated one;
|
|
558
|
+
3. validates `action.yml` against the Marketplace rules;
|
|
559
|
+
4. publishes to npm **only if the registry does not already have that version**;
|
|
560
|
+
5. creates the GitHub Release with the tarball;
|
|
561
|
+
6. force-moves the floating major tag (`v0`).
|
|
562
|
+
|
|
310
563
|
## License
|
|
311
564
|
|
|
565
|
+
|
|
312
566
|
MIT
|
package/action.yml
CHANGED
|
@@ -15,6 +15,10 @@ inputs:
|
|
|
15
15
|
description: "Inline configuration (JSON or YAML). Overrides the config repository."
|
|
16
16
|
required: false
|
|
17
17
|
default: ""
|
|
18
|
+
payload:
|
|
19
|
+
description: "Path to an event payload. A forwarded { event, payload } object is unwrapped."
|
|
20
|
+
required: false
|
|
21
|
+
default: ""
|
|
18
22
|
config-repo:
|
|
19
23
|
description: "Repository holding opencode-actions.yml, e.g. my-org/bot-config."
|
|
20
24
|
required: false
|
|
@@ -30,6 +34,14 @@ inputs:
|
|
|
30
34
|
github-token:
|
|
31
35
|
description: "Token used for GitHub operations. Needs contents, pull-requests, issues and actions scope."
|
|
32
36
|
required: true
|
|
37
|
+
app-id:
|
|
38
|
+
description: "GitHub App id. When set with app-private-key, the run acts as the app instead of the token."
|
|
39
|
+
required: false
|
|
40
|
+
default: ""
|
|
41
|
+
app-private-key:
|
|
42
|
+
description: "GitHub App private key (PEM). The installation token is minted per run and never stored."
|
|
43
|
+
required: false
|
|
44
|
+
default: ""
|
|
33
45
|
opencode-token:
|
|
34
46
|
description: "Token for the OpenCode service, if you use a managed provider."
|
|
35
47
|
required: false
|
|
@@ -82,6 +94,14 @@ inputs:
|
|
|
82
94
|
description: "Print the compiled configuration and exit without acting."
|
|
83
95
|
required: false
|
|
84
96
|
default: "false"
|
|
97
|
+
version:
|
|
98
|
+
description: "Exact npm version of the bot to install. Defaults to latest."
|
|
99
|
+
required: false
|
|
100
|
+
default: "latest"
|
|
101
|
+
opencode-version:
|
|
102
|
+
description: "OpenCode CLI version or 'stable'. The bot requires V2."
|
|
103
|
+
required: false
|
|
104
|
+
default: "stable"
|
|
85
105
|
|
|
86
106
|
outputs:
|
|
87
107
|
result:
|
|
@@ -98,23 +118,56 @@ outputs:
|
|
|
98
118
|
runs:
|
|
99
119
|
using: "composite"
|
|
100
120
|
steps:
|
|
101
|
-
- name: Install OpenCode
|
|
121
|
+
- name: Install OpenCode V2
|
|
122
|
+
shell: bash
|
|
123
|
+
env:
|
|
124
|
+
OPENCODE_CHANNEL: ${{ inputs.opencode-version }}
|
|
125
|
+
run: bash "${{ github.action_path }}/scripts/install-opencode.sh"
|
|
126
|
+
|
|
127
|
+
- name: Verify the runtime is V2
|
|
102
128
|
shell: bash
|
|
103
129
|
run: |
|
|
104
130
|
set -euo pipefail
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"$HOME/.opencode/bin/opencode" --version 2>/dev/null || opencode --version
|
|
131
|
+
echo "opencode2: $("${OPENCODE_BIN}" --version)"
|
|
132
|
+
# Guard against a silently wrong install: the generated configuration
|
|
133
|
+
# uses the V2 permissions ruleset, which a V1 runtime rejects.
|
|
134
|
+
"${OPENCODE_BIN}" --version | grep -Eq 'v?2\.' \
|
|
135
|
+
|| { echo "::error::expected OpenCode V2, got $("${OPENCODE_BIN}" --version)"; exit 1; }
|
|
111
136
|
|
|
112
137
|
- name: Install the bot package
|
|
113
138
|
shell: bash
|
|
139
|
+
env:
|
|
140
|
+
ACTION_REF: ${{ github.action_ref }}
|
|
141
|
+
INPUT_VERSION: ${{ inputs.version }}
|
|
114
142
|
run: |
|
|
115
143
|
set -euo pipefail
|
|
116
|
-
npm
|
|
117
|
-
|
|
144
|
+
# `github.action_ref` is a git ref (v0), not an npm version, so it must
|
|
145
|
+
# not be passed to npm. Only an exact semver ref is meaningful here.
|
|
146
|
+
VERSION="${INPUT_VERSION:-latest}"
|
|
147
|
+
if [ "${VERSION}" = "latest" ] && [[ "${ACTION_REF:-}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
148
|
+
VERSION="${ACTION_REF#v}"
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
echo "→ installing @eduardo191labs/opencode-actions@$VERSION (ref ${ACTION_REF:-none})"
|
|
152
|
+
|
|
153
|
+
# npm needs a moment before a freshly published version is resolvable.
|
|
154
|
+
# Retry rather than failing the whole run on propagation lag.
|
|
155
|
+
ATTEMPT=1
|
|
156
|
+
until npm install --prefix "$RUNNER_TEMP/opencode-actions" \
|
|
157
|
+
"@eduardo191labs/opencode-actions@$VERSION" --no-audit --no-fund; do
|
|
158
|
+
if [ "$ATTEMPT" -ge 5 ]; then
|
|
159
|
+
echo "::error::could not install @eduardo191labs/opencode-actions@$VERSION after $ATTEMPT attempts"
|
|
160
|
+
exit 1
|
|
161
|
+
fi
|
|
162
|
+
echo " attempt $ATTEMPT failed; retrying in 15s"
|
|
163
|
+
ATTEMPT=$((ATTEMPT + 1))
|
|
164
|
+
sleep 15
|
|
165
|
+
done
|
|
166
|
+
|
|
167
|
+
node -e '
|
|
168
|
+
const pkg = require(process.env.RUNNER_TEMP + "/opencode-actions/node_modules/@eduardo191labs/opencode-actions/package.json");
|
|
169
|
+
console.log("installed", pkg.name, pkg.version);
|
|
170
|
+
'
|
|
118
171
|
|
|
119
172
|
- name: Install and register plugins
|
|
120
173
|
if: inputs.plugins != ''
|
|
@@ -187,12 +240,17 @@ runs:
|
|
|
187
240
|
shell: bash
|
|
188
241
|
env:
|
|
189
242
|
GITHUB_TOKEN: ${{ inputs.github-token }}
|
|
243
|
+
# The app wins when both halves are present: the CLI exchanges the app
|
|
244
|
+
# JWT for an installation token and exports it as GITHUB_TOKEN.
|
|
245
|
+
OPENCODE_APP_ID: ${{ inputs.app-id || env.OPENCODE_APP_ID }}
|
|
246
|
+
OPENCODE_APP_PRIVATE_KEY: ${{ inputs.app-private-key || env.OPENCODE_APP_PRIVATE_KEY }}
|
|
190
247
|
OPENCODE_TOKEN: ${{ inputs.opencode-token }}
|
|
191
248
|
OPENCODE_ACTIONS_CONFIG_REPO: ${{ inputs.config-repo }}
|
|
192
249
|
OPENCODE_ACTIONS_CONFIG_REF: ${{ inputs.config-ref }}
|
|
193
250
|
OPENCODE_ACTIONS_CONFIG_TOKEN: ${{ inputs.config-token }}
|
|
194
251
|
OPENCODE_BOT_MODEL: ${{ inputs.model }}
|
|
195
252
|
OPENCODE_ACTIONS_EVENT: ${{ inputs.event }}
|
|
253
|
+
OPENCODE_BIN: ${{ env.OPENCODE_BIN }}
|
|
196
254
|
INPUT_CONFIG: ${{ inputs.config }}
|
|
197
255
|
INPUT_MODE: ${{ inputs.mode }}
|
|
198
256
|
INPUT_PR: ${{ inputs.pr }}
|
|
@@ -201,7 +259,10 @@ runs:
|
|
|
201
259
|
INPUT_LIVE: ${{ inputs.live }}
|
|
202
260
|
INPUT_SUMMARY: ${{ inputs.summary }}
|
|
203
261
|
INPUT_DRY_RUN: ${{ inputs.dry-run }}
|
|
262
|
+
INPUT_PAYLOAD: ${{ inputs.payload }}
|
|
204
263
|
OPENCODE_LOG_STYLE: github
|
|
264
|
+
# The configuration uses the V2 permissions ruleset; there is no V1 path.
|
|
265
|
+
OPENCODE_CONFIG_PROTOCOL: v2
|
|
205
266
|
run: |
|
|
206
267
|
set -euo pipefail
|
|
207
268
|
|
|
@@ -214,6 +275,7 @@ runs:
|
|
|
214
275
|
if [ -n "${INPUT_PR:-}" ]; then ARGS+=(--pr "$INPUT_PR"); fi
|
|
215
276
|
if [ -n "${INPUT_ISSUE:-}" ]; then ARGS+=(--issue "$INPUT_ISSUE"); fi
|
|
216
277
|
if [ -n "${INPUT_RUN_ID:-}" ]; then ARGS+=(--run-id "$INPUT_RUN_ID"); fi
|
|
278
|
+
if [ -n "${INPUT_PAYLOAD:-}" ]; then ARGS+=(--payload "$INPUT_PAYLOAD"); fi
|
|
217
279
|
if [ "${INPUT_DRY_RUN:-false}" = "true" ]; then ARGS+=(--dry-run); fi
|
|
218
280
|
|
|
219
281
|
BIN="$RUNNER_TEMP/opencode-actions/node_modules/@eduardo191labs/opencode-actions/dist/cli.js"
|