Skip to content

Commit baa6d98

Browse files
author
Perplexity Bot
committed
Initial scaffold for acpx-gh-action
0 parents  commit baa6d98

15 files changed

Lines changed: 2128 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Run ACPX Flow
2+
description: Set up acpx plus an agent CLI, inject secrets into the runtime env, and run a flow file.
3+
4+
inputs:
5+
flow-path:
6+
description: Path to the flow TypeScript file inside the checked-out repo.
7+
required: true
8+
default-agent:
9+
description: Agent id to pass to acpx --default-agent.
10+
required: true
11+
input-json:
12+
description: JSON object string passed to acpx --input-json.
13+
required: true
14+
setup-command:
15+
description: Shell command that installs acpx and any agent prerequisites.
16+
required: true
17+
github-token:
18+
description: GitHub token exposed to the flow as GH_TOKEN.
19+
required: true
20+
agent-auth-name:
21+
description: Optional env var name for the primary agent credential.
22+
required: false
23+
agent-auth-value:
24+
description: Optional secret value for the primary agent credential.
25+
required: false
26+
extra-env-json:
27+
description: Optional JSON object of extra env vars to export before running acpx.
28+
required: false
29+
default: "{}"
30+
31+
runs:
32+
using: composite
33+
steps:
34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: "24"
38+
39+
- name: Install acpx and agent prerequisites
40+
shell: bash
41+
run: ${{ inputs.setup-command }}
42+
43+
- name: Export flow environment
44+
shell: bash
45+
env:
46+
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
47+
INPUT_AGENT_AUTH_NAME: ${{ inputs.agent-auth-name }}
48+
INPUT_AGENT_AUTH_VALUE: ${{ inputs.agent-auth-value }}
49+
INPUT_EXTRA_ENV_JSON: ${{ inputs.extra-env-json }}
50+
run: |
51+
node <<'NODE'
52+
const fs = require("node:fs");
53+
54+
const envFile = process.env.GITHUB_ENV;
55+
const lines = [];
56+
57+
if (process.env.INPUT_GITHUB_TOKEN) {
58+
lines.push(`GH_TOKEN=${process.env.INPUT_GITHUB_TOKEN}`);
59+
}
60+
61+
const authName = String(process.env.INPUT_AGENT_AUTH_NAME ?? "").trim();
62+
const authValue = String(process.env.INPUT_AGENT_AUTH_VALUE ?? "");
63+
if (authName) {
64+
lines.push(`${authName}=${authValue}`);
65+
}
66+
67+
const extraEnvJson = String(process.env.INPUT_EXTRA_ENV_JSON ?? "").trim() || "{}";
68+
const extraEnv = JSON.parse(extraEnvJson);
69+
for (const [key, value] of Object.entries(extraEnv)) {
70+
lines.push(`${key}=${value ?? ""}`);
71+
}
72+
73+
fs.appendFileSync(envFile, `${lines.join("\n")}\n`);
74+
NODE
75+
76+
- name: Run flow
77+
shell: bash
78+
run: |
79+
acpx --approve-all flow run "${{ inputs.flow-path }}" \
80+
--default-agent "${{ inputs.default-agent }}" \
81+
--input-json '${{ inputs.input-json }}'

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
concurrency:
10+
group: ci-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 11.4.0
26+
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 24
31+
cache: pnpm
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Build
37+
run: pnpm run build
38+
39+
- name: Test
40+
run: pnpm run test

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: publish-${{ github.event.release.tag_name || github.ref }}
11+
cancel-in-progress: false
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
permissions:
18+
contents: read
19+
id-token: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: 11.4.0
29+
30+
- name: Set up Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: 24
34+
cache: pnpm
35+
registry-url: https://registry.npmjs.org
36+
37+
- name: Install dependencies
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Build
41+
run: pnpm run build
42+
43+
- name: Test
44+
run: pnpm run test
45+
46+
- name: Publish to npm
47+
run: pnpm publish --no-git-checks

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
node_modules
2+
dist
3+
coverage
4+
.vitest
5+
*.tsbuildinfo
6+
.serena
7+
8+
# Local environment
9+
.env
10+
.env.*
11+
!.env.example
12+
13+
# Logs
14+
*.log
15+
npm-debug.log*
16+
pnpm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
20+
# Editors and OS files
21+
.DS_Store
22+
.idea
23+
.vscode

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Nitay Rabi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# acpx-gh-action
2+
3+
`acpx-gh-action` scaffolds an ACPX-powered GitHub Actions workflow plus a matching `flows/*.ts` file.
4+
5+
The default scaffold listens for a specific GitHub issue label, runs a chosen coding agent against that issue inside the repository checkout, and opens a PR if the run produces changes.
6+
7+
This repo also now ships a reusable composite action at `.github/actions/run-acpx-flow`, so generated workflows can reference a real `uses:` target instead of inlining the `acpx` bootstrap.
8+
9+
## What it generates
10+
11+
- `.github/workflows/<flow-name>.yml`
12+
- `flows/<flow-name>.ts`
13+
14+
The scaffold source lives in Handlebars templates:
15+
16+
- `templates/default/workflow.yml.hbs`
17+
- `templates/default/flow.ts.hbs`
18+
19+
## Usage
20+
21+
```bash
22+
pnpm install
23+
pnpm run build
24+
node dist/cli.js init
25+
```
26+
27+
## CI And Publishing
28+
29+
This repo includes:
30+
31+
- `.github/workflows/ci.yml` to run `pnpm install --frozen-lockfile`, `pnpm run build`, and `pnpm run test`
32+
- `.github/workflows/publish.yml` to publish to npm from GitHub Actions using trusted publishing
33+
34+
To use secure npm publishing, configure npm to trust this repository and the `.github/workflows/publish.yml` workflow as a trusted publisher. With npm trusted publishing on GitHub-hosted runners, OIDC is used instead of an `NPM_TOKEN`, and provenance is generated automatically.
35+
36+
The CLI prompts for:
37+
38+
- flow name
39+
- workflow display name
40+
- reusable action reference
41+
- coding agent from the current `acpx` built-in list
42+
- runner setup command for `acpx` plus the chosen agent
43+
- primary auth secret env var to expose
44+
- GitHub issue label to respond to
45+
- extra GitHub secret names to expose as environment variables
46+
- target repository directory
47+
48+
## Generated workflow behavior
49+
50+
The scaffolded workflow:
51+
52+
1. Triggers on `issues.opened` and `issues.labeled`
53+
2. Runs only when the configured label is present on the issue
54+
3. Checks out the target repository
55+
4. Calls a reusable action via `uses: <your-action-ref>`
56+
5. Runs `acpx --approve-all flow run flows/<flow>.ts`
57+
6. Opens a PR and comments on the issue when code changes were produced
58+
59+
Example:
60+
61+
```yaml
62+
- name: Run Codex Review
63+
uses: your-org/acpx-gh-action/.github/actions/run-acpx-flow@main
64+
with:
65+
flow-path: flows/issue-label-agent.ts
66+
default-agent: codex
67+
input-json: '{"repo":"${{ github.repository }}","issueNumber":${{ github.event.issue.number }}}'
68+
setup-command: npm install -g acpx @openai/codex
69+
github-token: ${{ github.token }}
70+
agent-auth-name: OPENAI_API_KEY
71+
agent-auth-value: ${{ secrets.OPENAI_API_KEY }}
72+
```
73+
74+
## Secrets
75+
76+
Known default auth secret suggestions:
77+
78+
- `codex`: `OPENAI_API_KEY`
79+
- `claude`: `ANTHROPIC_API_KEY`
80+
- `gemini`: `GEMINI_API_KEY`
81+
82+
Other agents vary, so the CLI lets you override the primary auth env var and setup command directly. Any extra secret names entered in the CLI are added to the workflow `env` block as `${{ secrets.NAME }}`.

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "acpx-gh-action",
3+
"version": "0.1.0",
4+
"description": "CLI to scaffold ACPX-powered GitHub issue label automations.",
5+
"type": "module",
6+
"packageManager": "pnpm@11.4.0",
7+
"bin": {
8+
"acpx-gh-action": "dist/cli.js"
9+
},
10+
"files": [
11+
"dist",
12+
"templates",
13+
".github/actions",
14+
"README.md"
15+
],
16+
"scripts": {
17+
"build": "tsc -p tsconfig.json",
18+
"check": "pnpm run build && pnpm run test",
19+
"test": "vitest run"
20+
},
21+
"engines": {
22+
"node": ">=20"
23+
},
24+
"devDependencies": {
25+
"@types/node": "^24.0.1",
26+
"handlebars": "^4.7.8",
27+
"typescript": "^5.8.3",
28+
"vitest": "^3.2.4"
29+
}
30+
}

0 commit comments

Comments
 (0)