Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c753dc0a0 | ||
|
|
23c48e66c4 | ||
|
|
6618de9c9f | ||
|
|
82c4b07fea |
@@ -1,6 +1,6 @@
|
|||||||
name: agent
|
name: agent
|
||||||
# Reusable AI-agent workflow, shared across repos. A caller repo triggers on issue_comment/issues
|
# Reusable AI-agent workflow, shared across repos. A caller repo triggers on issue_comment/issues
|
||||||
# and invokes this via: uses: ffaerber/agents/.gitea/workflows/agent.yml@main (secrets: inherit).
|
# and invokes this via: uses: gitea/agents/.gitea/workflows/agent.yml@main (secrets: inherit).
|
||||||
# The gate + steps run in the caller's event context (github.event.* / github.repository are the caller's).
|
# The gate + steps run in the caller's event context (github.event.* / github.repository are the caller's).
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
- name: Fetch shared agent scripts (this repo)
|
- name: Fetch shared agent scripts (this repo)
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
repository: ffaerber/agents
|
repository: gitea/agents
|
||||||
ref: main
|
ref: main
|
||||||
path: .agents-workflow
|
path: .agents-workflow
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
token: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: ai-agent
|
name: ai-agent
|
||||||
run-name: "ai-agent · #${{ github.event.issue.number }}" # quotes required: bare # starts a YAML comment
|
run-name: "ai-agent · #${{ github.event.issue.number }}" # quotes required: bare # starts a YAML comment
|
||||||
# Standard caller for the shared AI-agent workflow (ffaerber/agents). Copy this file VERBATIM into
|
# Standard caller for the shared AI-agent workflow (gitea/agents). Copy this file VERBATIM into
|
||||||
# any repo that should get the agents — it is identical in every repo. All logic + scripts live in
|
# any repo that should get the agents — it is identical in every repo. All logic + scripts live in
|
||||||
# agents/.gitea/workflows/; scripts are fetched from @main at run time. The `jobs.agent` wrapper is
|
# agents/.gitea/workflows/; scripts are fetched from @main at run time. The `jobs.agent` wrapper is
|
||||||
# required: a reusable (workflow_call) workflow can only be invoked from a caller job, not top-level.
|
# required: a reusable (workflow_call) workflow can only be invoked from a caller job, not top-level.
|
||||||
@@ -11,5 +11,5 @@ on:
|
|||||||
types: [opened]
|
types: [opened]
|
||||||
jobs:
|
jobs:
|
||||||
agent:
|
agent:
|
||||||
uses: ffaerber/agents/.gitea/workflows/agent.yml@main
|
uses: gitea/agents/.gitea/workflows/agent.yml@main
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|||||||
@@ -59,20 +59,24 @@ curl -sS -X POST -H "Authorization: token $AGENT_TOKEN" -H "Content-Type: applic
|
|||||||
# 2) mint a scoped token AS that user (pick the narrowest scopes needed)
|
# 2) mint a scoped token AS that user (pick the narrowest scopes needed)
|
||||||
tok=$(curl -sS -u "inter:$PW" -H "Content-Type: application/json" -X POST "$API/users/inter/tokens" \
|
tok=$(curl -sS -u "inter:$PW" -H "Content-Type: application/json" -X POST "$API/users/inter/tokens" \
|
||||||
-d '{"name":"inter","scopes":["read:repository","write:issue"]}' | jq -r '.sha1')
|
-d '{"name":"inter","scopes":["read:repository","write:issue"]}' | jq -r '.sha1')
|
||||||
# 3) store it as a secret (org / repo / user level) — never print $tok
|
# 3) store the value in BOTH places (see "Secret storage" below) — never print $tok
|
||||||
curl -sS -X PUT -H "Authorization: token $AGENT_TOKEN" -H "Content-Type: application/json" \
|
curl -sS -X PUT -H "Authorization: token $AGENT_TOKEN" -H "Content-Type: application/json" \
|
||||||
"$API/orgs/gitea/actions/secrets/TOKEN_INTER" -d "$(jq -nc --arg d "$tok" '{data:$d}')"
|
"$API/orgs/gitea/actions/secrets/TOKEN_INTER" -d "$(jq -nc --arg d "$tok" '{data:$d}')"
|
||||||
```
|
```
|
||||||
Token **scopes** are groups of `read:`/`write:` on: `repository`, `issue`, `organization`, `user`,
|
Token **scopes** are groups of `read:`/`write:` on: `repository`, `issue`, `organization`, `user`,
|
||||||
`package`, `notification`, `misc`, and (only for a privileged token) `admin`.
|
`package`, `notification`, `misc`, and (only for a privileged token) `admin`.
|
||||||
|
|
||||||
## Token inventory — record everything in `gitea/secrets`
|
## Secret storage — `gitea/secrets/.env` is the SOURCE OF TRUTH
|
||||||
The private repo **`gitea/secrets`** (readable only by @ffaerber and @ops) is the source of truth for
|
Every token/secret value MUST live in **`gitea/secrets/.env`** (private, readable only by @ffaerber and
|
||||||
tokens. Whenever you mint, rotate, or re-scope a token, append/update a row in its `tokens.md` via the
|
@ops) as a `KEY=value` line. That file is the master; the workflows only get a secret because `.env` is
|
||||||
contents API (`GET` the file for its `sha`, then `PUT` the updated base64 content with that `sha`):
|
mirrored into the org Actions secrets. So whenever you mint, rotate, or re-scope a token you MUST do
|
||||||
`| <token/secret name> | <owner user> | <scopes> | <Actions secret it is stored in> | <notes> |`.
|
BOTH, in sync:
|
||||||
Storing the live value in the matching Actions secret is what workflows use; the `gitea/secrets` row
|
1. **`.env`**: `GET /repos/gitea/secrets/contents/.env` for its `sha`, add or replace the `KEY=value`
|
||||||
is the human-readable inventory. Never paste a token value into any issue/PR/comment/log.
|
line, then `PUT` the updated base64 content with that `sha`.
|
||||||
|
2. **Actions secret**: `PUT /orgs/gitea/actions/secrets/{KEY}` with the same value (what runs use).
|
||||||
|
When you DELETE a token, remove it from BOTH. Keep `gitea/secrets/README.md` (the table describing what
|
||||||
|
each KEY is) up to date. Do NOT use `tokens.md` — the values live in `.env`. NEVER paste a token value
|
||||||
|
into any issue/PR/comment/log; it only ever goes into `.env` and the Actions secret.
|
||||||
|
|
||||||
## Change a user's token scope (the "update my token" flow)
|
## Change a user's token scope (the "update my token" flow)
|
||||||
Tokens are immutable — you can't edit scopes. Re-mint: delete the old token and create a new one,
|
Tokens are immutable — you can't edit scopes. Re-mint: delete the old token and create a new one,
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ it is the source of truth, and `agents` itself uses the same file:
|
|||||||
```yaml
|
```yaml
|
||||||
name: ai-agent
|
name: ai-agent
|
||||||
run-name: "ai-agent · #${{ github.event.issue.number }}" # quotes required: bare # starts a YAML comment
|
run-name: "ai-agent · #${{ github.event.issue.number }}" # quotes required: bare # starts a YAML comment
|
||||||
# Standard caller for the shared AI-agent workflow (ffaerber/agents). Copy this file VERBATIM into
|
# Standard caller for the shared AI-agent workflow (gitea/agents). Copy this file VERBATIM into
|
||||||
# any repo that should get the agents — it is identical in every repo. All logic + scripts live in
|
# any repo that should get the agents — it is identical in every repo. All logic + scripts live in
|
||||||
# agents/.gitea/workflows/; scripts are fetched from @main at run time. The `jobs.agent` wrapper is
|
# agents/.gitea/workflows/; scripts are fetched from @main at run time. The `jobs.agent` wrapper is
|
||||||
# required: a reusable (workflow_call) workflow can only be invoked from a caller job, not top-level.
|
# required: a reusable (workflow_call) workflow can only be invoked from a caller job, not top-level.
|
||||||
@@ -49,7 +49,7 @@ on:
|
|||||||
types: [opened]
|
types: [opened]
|
||||||
jobs:
|
jobs:
|
||||||
agent:
|
agent:
|
||||||
uses: ffaerber/agents/.gitea/workflows/agent.yml@main
|
uses: gitea/agents/.gitea/workflows/agent.yml@main
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user