Skip to content

Commit 6145ad5

Browse files
ryan-williamsclaude
andcommitted
Replace reusable workflows with composite actions
Composite actions are invocable as steps (not jobs), giving callers full control over their workflow. Usage from downstream repos: \`\`\`yaml - uses: Open-Athena/discord-agent/actions/deploy-app@v1 with: pages_project_name: my-project vite_api_base: https://my-worker.workers.dev cloudflare_token: \${{ secrets.CLOUDFLARE_TOKEN }} cloudflare_account_id: \${{ secrets.CLOUDFLARE_ACCOUNT_ID }} \`\`\` Three actions: - \`actions/deploy-app\` — build viewer, deploy to CF Pages - \`actions/deploy-worker\` — deploy D1-backed Worker API - \`actions/update-archive\` — fetch new messages, rebuild DB, sync D1 Each checks out discord-agent at the specified ref (default \`v1\`), so callers only need their own config (wrangler.toml, .dvc/config). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fe621d4 commit 6145ad5

File tree

6 files changed

+205
-164
lines changed

6 files changed

+205
-164
lines changed

.github/workflows/deploy-app.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/deploy-worker.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/update-archive.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

actions/deploy-app/action.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy Discord Archive Viewer
2+
description: Build and deploy the viewer app to Cloudflare Pages
3+
4+
inputs:
5+
pages_project_name:
6+
description: Cloudflare Pages project name
7+
required: true
8+
vite_api_base:
9+
description: API base URL baked into the build
10+
required: true
11+
cloudflare_token:
12+
description: Cloudflare API token
13+
required: true
14+
cloudflare_account_id:
15+
description: Cloudflare account ID
16+
required: true
17+
ref:
18+
description: discord-agent ref to build from
19+
default: v1
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
repository: Open-Athena/discord-agent
27+
ref: ${{ inputs.ref }}
28+
path: .discord-agent
29+
- uses: pnpm/action-setup@v4
30+
with:
31+
version: 10
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: 22
35+
cache: pnpm
36+
cache-dependency-path: .discord-agent/app/pnpm-lock.yaml
37+
- run: pnpm install --frozen-lockfile
38+
shell: bash
39+
working-directory: .discord-agent/app
40+
- run: pnpm build
41+
shell: bash
42+
working-directory: .discord-agent/app
43+
env:
44+
VITE_API_BASE: ${{ inputs.vite_api_base }}
45+
- uses: cloudflare/wrangler-action@v3
46+
with:
47+
apiToken: ${{ inputs.cloudflare_token }}
48+
accountId: ${{ inputs.cloudflare_account_id }}
49+
command: pages deploy dist --project-name ${{ inputs.pages_project_name }}
50+
workingDirectory: .discord-agent/app

actions/deploy-worker/action.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy Discord Archive Worker API
2+
description: Deploy the D1-backed API worker to Cloudflare
3+
4+
inputs:
5+
cloudflare_token:
6+
description: Cloudflare API token
7+
required: true
8+
cloudflare_account_id:
9+
description: Cloudflare account ID
10+
required: true
11+
wrangler_toml:
12+
description: Path to wrangler.toml in the caller's repo (copied over discord-agent's default)
13+
default: ""
14+
ref:
15+
description: discord-agent ref to build from
16+
default: v1
17+
18+
runs:
19+
using: composite
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
repository: Open-Athena/discord-agent
24+
ref: ${{ inputs.ref }}
25+
path: .discord-agent
26+
- name: Override wrangler.toml from caller
27+
if: ${{ inputs.wrangler_toml != '' }}
28+
shell: bash
29+
run: cp "${{ inputs.wrangler_toml }}" .discord-agent/api/wrangler.toml
30+
- uses: pnpm/action-setup@v4
31+
with:
32+
version: 10
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 22
36+
cache: pnpm
37+
cache-dependency-path: .discord-agent/api/pnpm-lock.yaml
38+
- run: pnpm install --frozen-lockfile
39+
shell: bash
40+
working-directory: .discord-agent/api
41+
- uses: cloudflare/wrangler-action@v3
42+
with:
43+
apiToken: ${{ inputs.cloudflare_token }}
44+
accountId: ${{ inputs.cloudflare_account_id }}
45+
command: deploy
46+
workingDirectory: .discord-agent/api

actions/update-archive/action.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Update Discord Archive
2+
description: Fetch new messages, rebuild DB, sync to D1, push to DVX remote
3+
4+
inputs:
5+
discord_token:
6+
description: Discord bot token
7+
required: true
8+
cloudflare_token:
9+
description: Cloudflare API token
10+
required: true
11+
full_reimport:
12+
description: Full reimport (drop + recreate) instead of incremental
13+
default: "false"
14+
wrangler_toml:
15+
description: Path to wrangler.toml in the caller's repo
16+
default: ""
17+
ref:
18+
description: discord-agent ref
19+
default: v1
20+
21+
runs:
22+
using: composite
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
repository: Open-Athena/discord-agent
27+
ref: ${{ inputs.ref }}
28+
path: .discord-agent
29+
30+
- uses: astral-sh/setup-uv@v5
31+
with:
32+
version: latest
33+
34+
- uses: pnpm/action-setup@v4
35+
with:
36+
version: 10
37+
38+
- uses: actions/setup-node@v4
39+
with:
40+
node-version: 22
41+
cache: pnpm
42+
cache-dependency-path: .discord-agent/api/pnpm-lock.yaml
43+
44+
- run: pip install dvx
45+
shell: bash
46+
47+
# Pull existing archive
48+
- run: dvx pull
49+
shell: bash
50+
env:
51+
AWS_PROFILE: ""
52+
53+
# Fetch new messages
54+
- run: uv run .discord-agent/archive.py
55+
shell: bash
56+
env:
57+
DISCORD_TOKEN: ${{ inputs.discord_token }}
58+
59+
# Rebuild SQLite
60+
- run: uv run .discord-agent/build_db.py
61+
shell: bash
62+
63+
# Update DVX cache
64+
- run: dvx add archive && dvx push
65+
shell: bash
66+
env:
67+
AWS_PROFILE: ""
68+
69+
# Override wrangler.toml if provided
70+
- name: Override wrangler.toml
71+
if: ${{ inputs.wrangler_toml != '' }}
72+
shell: bash
73+
run: cp "${{ inputs.wrangler_toml }}" .discord-agent/api/wrangler.toml
74+
75+
- run: pnpm install --frozen-lockfile
76+
shell: bash
77+
working-directory: .discord-agent/api
78+
79+
# Incremental D1 sync
80+
- name: Incremental D1 sync
81+
if: ${{ inputs.full_reimport != 'true' }}
82+
shell: bash
83+
working-directory: .discord-agent/api
84+
run: uv run d1-sync.py --remote
85+
env:
86+
CLOUDFLARE_TOKEN: ${{ inputs.cloudflare_token }}
87+
88+
# Full reimport
89+
- name: Full D1 reimport
90+
if: ${{ inputs.full_reimport == 'true' }}
91+
shell: bash
92+
working-directory: .discord-agent/api
93+
run: ./d1-import.sh --remote ../../archive.db
94+
env:
95+
CLOUDFLARE_TOKEN: ${{ inputs.cloudflare_token }}
96+
97+
# Commit updated archive.dvc
98+
- name: Commit archive update
99+
shell: bash
100+
run: |
101+
git config user.name "github-actions[bot]"
102+
git config user.email "github-actions[bot]@users.noreply.github.com"
103+
if git diff --quiet archive.dvc; then
104+
echo "No archive changes"
105+
else
106+
git add archive.dvc
107+
git commit -m "Update archive $(date -u +%Y-%m-%d)"
108+
git push
109+
fi

0 commit comments

Comments
 (0)