Skip to content

Commit 5496909

Browse files
committed
ci: allow canvas sync without version bump
Make marketplace_version optional, preserve plugin metadata when omitted, derive PR metadata from the source commit, and checkout the automation helper from the workflow revision so branch-based E2E tests can run safely.
1 parent 3d95f8f commit 5496909

2 files changed

Lines changed: 75 additions & 30 deletions

File tree

.github/scripts/sync_foundry_agent_canvas.mjs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { join, resolve } from "node:path";
1313
const [sourceArg, targetArg, pluginManifestArg, nextVersion] =
1414
process.argv.slice(2);
1515

16-
if (!sourceArg || !targetArg || !pluginManifestArg || !nextVersion) {
16+
if (!sourceArg || !targetArg || !pluginManifestArg) {
1717
throw new Error(
18-
"Usage: sync_foundry_agent_canvas.mjs <source-package> <target-extension> <plugin-manifest> <version>",
18+
"Usage: sync_foundry_agent_canvas.mjs <source-package> <target-extension> <plugin-manifest> [version]",
1919
);
2020
}
2121

@@ -75,15 +75,20 @@ if (extensionManifest.name !== "foundry-agent-canvas") {
7575
throw new Error(`Unexpected extension name: ${extensionManifest.name}`);
7676
}
7777

78-
const currentParsedVersion = parseVersion(
79-
pluginManifest.version,
80-
"Current plugin version",
81-
);
82-
const nextParsedVersion = parseVersion(nextVersion, "Requested plugin version");
83-
if (compareVersions(nextParsedVersion, currentParsedVersion) <= 0) {
84-
throw new Error(
85-
`Requested plugin version ${nextVersion} must be newer than ${pluginManifest.version}`,
78+
if (nextVersion) {
79+
const currentParsedVersion = parseVersion(
80+
pluginManifest.version,
81+
"Current plugin version",
82+
);
83+
const nextParsedVersion = parseVersion(
84+
nextVersion,
85+
"Requested plugin version",
8686
);
87+
if (compareVersions(nextParsedVersion, currentParsedVersion) <= 0) {
88+
throw new Error(
89+
`Requested plugin version ${nextVersion} must be newer than ${pluginManifest.version}`,
90+
);
91+
}
8792
}
8893

8994
for (const entry of payload) {
@@ -97,12 +102,17 @@ for (const entry of payload) {
97102
});
98103
}
99104

100-
pluginManifest.version = nextVersion;
101-
writeFileSync(
102-
pluginManifestPath,
103-
`${JSON.stringify(pluginManifest, null, 2)}\n`,
104-
);
105-
106-
console.log(
107-
`Synced foundry-agent-canvas payload and updated plugin version to ${nextVersion}`,
108-
);
105+
if (nextVersion) {
106+
pluginManifest.version = nextVersion;
107+
writeFileSync(
108+
pluginManifestPath,
109+
`${JSON.stringify(pluginManifest, null, 2)}\n`,
110+
);
111+
console.log(
112+
`Synced foundry-agent-canvas payload and updated plugin version to ${nextVersion}`,
113+
);
114+
} else {
115+
console.log(
116+
`Synced foundry-agent-canvas payload and preserved plugin version ${pluginManifest.version}`,
117+
);
118+
}

.github/workflows/sync-foundry-agent-canvas.yml

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ on:
99
default: "main"
1010
type: string
1111
marketplace_version:
12-
description: "New marketplace version using stable X.Y.Z format"
13-
required: true
12+
description: "Optional new marketplace version using stable X.Y.Z format"
13+
required: false
1414
type: string
1515

1616
permissions:
1717
contents: read
1818

19+
env:
20+
CANVAS_SOURCE_REF: ${{ inputs.source_ref || 'main' }}
21+
MARKETPLACE_VERSION: ${{ inputs.marketplace_version || '' }}
22+
1923
concurrency:
2024
group: sync-foundry-agent-canvas
2125
cancel-in-progress: false
@@ -34,7 +38,7 @@ jobs:
3438
uses: actions/checkout@v4
3539
with:
3640
repository: SmallBlackHole/foundry-agent-canvas
37-
ref: ${{ inputs.source_ref }}
41+
ref: ${{ env.CANVAS_SOURCE_REF }}
3842
path: source
3943
persist-credentials: false
4044

@@ -92,6 +96,13 @@ jobs:
9296
contents: read
9397

9498
steps:
99+
- name: Checkout workflow automation
100+
uses: actions/checkout@v4
101+
with:
102+
ref: ${{ github.sha }}
103+
path: automation
104+
persist-credentials: false
105+
95106
- name: Generate GitHub App token
96107
id: app-token
97108
uses: actions/create-github-app-token@v1
@@ -115,11 +126,35 @@ jobs:
115126

116127
- name: Sync runtime package
117128
run: |
118-
node target/.github/scripts/sync_foundry_agent_canvas.mjs \
129+
node automation/.github/scripts/sync_foundry_agent_canvas.mjs \
119130
bundle \
120131
target/foundry-agent-canvas/extensions/foundry-agent-canvas \
121132
target/foundry-agent-canvas/.github/plugin/plugin.json \
122-
"${{ inputs.marketplace_version }}"
133+
"$MARKETPLACE_VERSION"
134+
135+
- name: Resolve pull request metadata
136+
id: metadata
137+
shell: bash
138+
env:
139+
SOURCE_SHORT_SHA: ${{ needs.build.outputs.source_short_sha }}
140+
run: |
141+
set -euo pipefail
142+
143+
if [[ -n "$MARKETPLACE_VERSION" ]]; then
144+
branch_suffix="v$MARKETPLACE_VERSION"
145+
title="chore: sync foundry-agent-canvas v$MARKETPLACE_VERSION"
146+
version_label="$MARKETPLACE_VERSION"
147+
else
148+
branch_suffix="$SOURCE_SHORT_SHA"
149+
title="chore: sync foundry-agent-canvas ($SOURCE_SHORT_SHA)"
150+
version_label="unchanged"
151+
fi
152+
153+
{
154+
echo "branch_suffix=$branch_suffix"
155+
echo "title=$title"
156+
echo "version_label=$version_label"
157+
} >> "$GITHUB_OUTPUT"
123158
124159
- name: Detect package changes
125160
id: diff
@@ -146,7 +181,7 @@ jobs:
146181
echo "## Foundry Agent Canvas Sync"
147182
echo
148183
echo "- Source: \`SmallBlackHole/foundry-agent-canvas@${{ needs.build.outputs.source_sha }}\`"
149-
echo "- Marketplace version: \`${{ inputs.marketplace_version }}\`"
184+
echo "- Marketplace version: \`${{ steps.metadata.outputs.version_label }}\`"
150185
echo
151186
echo "### Changed files"
152187
echo
@@ -163,20 +198,20 @@ jobs:
163198
token: ${{ steps.app-token.outputs.token }}
164199
path: target
165200
base: main
166-
branch: bot/sync-foundry-agent-canvas-v${{ inputs.marketplace_version }}
201+
branch: bot/sync-foundry-agent-canvas-${{ steps.metadata.outputs.branch_suffix }}
167202
delete-branch: true
168203
draft: always-true
169-
commit-message: "chore: sync foundry-agent-canvas v${{ inputs.marketplace_version }}"
170-
title: "chore: sync foundry-agent-canvas v${{ inputs.marketplace_version }}"
204+
commit-message: ${{ steps.metadata.outputs.title }}
205+
title: ${{ steps.metadata.outputs.title }}
171206
body: |
172207
## Summary
173208
This automated draft PR updates the bundled Foundry Agent Canvas runtime.
174209
175210
## Source
176211
- Repository: `SmallBlackHole/foundry-agent-canvas`
177-
- Requested ref: `${{ inputs.source_ref }}`
212+
- Requested ref: `${{ env.CANVAS_SOURCE_REF }}`
178213
- Resolved commit: `${{ needs.build.outputs.source_sha }}`
179-
- Marketplace version: `${{ inputs.marketplace_version }}`
214+
- Marketplace version: `${{ steps.metadata.outputs.version_label }}`
180215
- Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
181216
182217
## Validation

0 commit comments

Comments
 (0)