Skip to content

Commit ee999e3

Browse files
committed
API update
1 parent 516fcce commit ee999e3

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

.github/workflows/update-api.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010

11-
jobs:
11+
jobs:
1212
notify_discord_start:
1313
runs-on: ubuntu-latest
1414
steps:
@@ -20,6 +20,11 @@ jobs:
2020

2121
api:
2222
runs-on: ubuntu-latest
23+
outputs:
24+
uploaded_count: ${{ steps.build.outputs.uploaded_count }}
25+
uploaded_versions: ${{ steps.build.outputs.uploaded_versions }}
26+
versions_checked: ${{ steps.build.outputs.versions_checked }}
27+
duration: ${{ steps.build.outputs.duration }}
2328
steps:
2429
- uses: actions/checkout@v2
2530

@@ -34,6 +39,7 @@ jobs:
3439
run: npm install
3540

3641
- name: Update needle engine api
42+
id: build
3743
run: npm run docs:build-api
3844
env:
3945
API_FTP_USER: ${{ secrets.API_FTP_USER }}
@@ -45,7 +51,15 @@ jobs:
4551
runs-on: ubuntu-latest
4652
steps:
4753
- uses: tsickert/discord-webhook@v5.3.0
54+
if: ${{ needs.api.outputs.uploaded_count != '0' }}
4855
with:
4956
webhook-url: ${{ secrets.DEPLOY_DISCORD_WEBHOOK }}
5057
username: "Update Api 🤖"
51-
content: "API has been updated → <https://engine.needle.tools/docs/api>"
58+
content: "API updated: uploaded ${{ needs.api.outputs.uploaded_count }} new version(s) (${{ needs.api.outputs.uploaded_versions }}) — checked ${{ needs.api.outputs.versions_checked }} versions in ${{ needs.api.outputs.duration }} min → https://engine.needle.tools/docs/api"
59+
60+
- uses: tsickert/discord-webhook@v5.3.0
61+
if: ${{ needs.api.outputs.uploaded_count == '0' }}
62+
with:
63+
webhook-url: ${{ secrets.DEPLOY_DISCORD_WEBHOOK }}
64+
username: "Update Api 🤖"
65+
content: "API is up to date — checked ${{ needs.api.outputs.versions_checked }} versions in ${{ needs.api.outputs.duration }} min → https://engine.needle.tools/docs/api"

tools/build_api_docs.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,21 @@ async function main() {
160160

161161
console.log("Uploaded API documentations: " + uploaded.length + ":\n" + uploaded.map(u => "https://engine.needle.tools/docs/api/" + u).join("\n"));
162162
// log duration in minutes
163-
console.log("Finished in " + ((new Date().getTime() - startTime) / 1000 / 60).toFixed(2) + " minutes");
163+
const durationMin = ((new Date().getTime() - startTime) / 1000 / 60).toFixed(2);
164+
console.log("Finished in " + durationMin + " minutes");
165+
166+
// Write summary to GITHUB_OUTPUT for the workflow notification
167+
if (isGithubActions && process.env.GITHUB_OUTPUT) {
168+
const outputFile = process.env.GITHUB_OUTPUT;
169+
const lines = [];
170+
lines.push(`uploaded_count=${uploaded.length}`);
171+
lines.push(`versions_checked=${versionsChecked}`);
172+
if (uploaded.length > 0) {
173+
lines.push(`uploaded_versions=${uploaded.join(", ")}`);
174+
}
175+
lines.push(`duration=${durationMin}`);
176+
fs.appendFileSync(outputFile, lines.join("\n") + "\n");
177+
}
164178

165179
}
166180

0 commit comments

Comments
 (0)