diff --git a/.github/actions/gh-cc-table/main.js b/.github/action-scripts/updateCCImplementationOverview.js
similarity index 62%
rename from .github/actions/gh-cc-table/main.js
rename to .github/action-scripts/updateCCImplementationOverview.js
index 3b35a94cac35..a8423d210458 100644
--- a/.github/actions/gh-cc-table/main.js
+++ b/.github/action-scripts/updateCCImplementationOverview.js
@@ -1,13 +1,19 @@
+// Updates the CC implementation status table in issue 6
+
+// @ts-check
+///
+
const c = require("ansi-colors");
const exec = require("@actions/exec");
-const github = require("@actions/github");
-const core = require("@actions/core");
-const githubToken = core.getInput("githubToken");
-const octokit = github.getOctokit(githubToken).rest;
-const context = github.context;
+const ISSUE_NUMBER = 6;
+
+/**
+ * @param {{github: Github, context: Context}} param
+ */
+async function main(param) {
+ const { github, context } = param;
-(async function main() {
let ccTable = "";
const options = {};
@@ -31,21 +37,22 @@ const context = github.context;
const {
data: { body: oldBody },
- } = await octokit.issues.get({
+ } = await github.rest.issues.get({
...context.repo,
- issue_number: 6,
+ issue_number: ISSUE_NUMBER,
});
const newBody = ccTable;
if (oldBody !== newBody) {
- await octokit.issues.update({
+ await github.rest.issues.update({
...context.repo,
- issue_number: 6,
+ issue_number: ISSUE_NUMBER,
body: newBody,
});
console.error(c.green("The implementation table was updated!"));
} else {
console.error(c.yellow("No changes to the implementation table!"));
}
-})();
+}
+module.exports = main;
diff --git a/.github/actions/toLogEntry/main.js b/.github/action-scripts/updateToLogEntryOverview.js
similarity index 63%
rename from .github/actions/toLogEntry/main.js
rename to .github/action-scripts/updateToLogEntryOverview.js
index 90c6ab735148..72f8620480d7 100644
--- a/.github/actions/toLogEntry/main.js
+++ b/.github/action-scripts/updateToLogEntryOverview.js
@@ -1,13 +1,19 @@
+// Updates the toLogEntry implementation status table in issue 54
+
+// @ts-check
+///
+
const c = require("ansi-colors");
const exec = require("@actions/exec");
-const github = require("@actions/github");
-const core = require("@actions/core");
-const githubToken = core.getInput("githubToken");
-const octokit = github.getOctokit(githubToken).rest;
-const context = github.context;
+const ISSUE_NUMBER = 54;
+
+/**
+ * @param {{github: Github, context: Context}} param
+ */
+async function main(param) {
+ const { github, context } = param;
-(async function main() {
let result = "";
/** @type {exec.ExecOptions} */
@@ -23,9 +29,9 @@ const context = github.context;
const {
data: { body: oldBody },
- } = await octokit.issues.get({
+ } = await github.rest.issues.get({
...context.repo,
- issue_number: 54,
+ issue_number: ISSUE_NUMBER,
});
const newBody = `current implementation status:
@@ -33,9 +39,9 @@ const context = github.context;
${result}`;
if (oldBody !== newBody) {
- await octokit.issues.update({
+ await github.rest.issues.update({
...context.repo,
- issue_number: 54,
+ issue_number: ISSUE_NUMBER,
body: newBody,
// Auto-close or open the issue when everything is done (or not)
state: result.trim().endsWith(":)") ? "closed" : "open",
@@ -44,4 +50,5 @@ ${result}`;
} else {
console.error(c.yellow("No changes to the implementation status!"));
}
-})();
+}
+module.exports = main;
diff --git a/.github/actions/gh-cc-table/action.yml b/.github/actions/gh-cc-table/action.yml
deleted file mode 100644
index 9df7a58b81be..000000000000
--- a/.github/actions/gh-cc-table/action.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-name: 'CC-Table'
-description: 'Keep CC implementation status in #6 up to date'
-author: 'AlCalzone'
-inputs:
- githubToken:
- description: 'The github token to use for authentication'
- required: true
-runs:
- using: 'node20'
- main: 'main.js'
diff --git a/.github/actions/toLogEntry/action.yml b/.github/actions/toLogEntry/action.yml
deleted file mode 100644
index 1522d7e31bf1..000000000000
--- a/.github/actions/toLogEntry/action.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-name: 'toLogEntry implementation overview'
-description: 'Keep toLogEntry implementation status in #54 up to date'
-author: 'AlCalzone'
-inputs:
- githubToken:
- description: 'The github token to use for authentication'
- required: true
-runs:
- using: 'node20'
- main: 'main.js'
diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml
index b2f36a43b393..5df2b688f6d3 100644
--- a/.github/workflows/test-and-release.yml
+++ b/.github/workflows/test-and-release.yml
@@ -295,7 +295,10 @@ jobs:
gh-cc-table:
name: Update CC implementation status
# Only run for master branch and don't run in forks
- if: github.repository == 'zwave-js/node-zwave-js' && github.ref == 'refs/heads/master' && github.event_name == 'push'
+ if: |
+ github.repository == 'zwave-js/node-zwave-js' &&
+ github.ref == 'refs/heads/master' &&
+ github.event_name == 'push'
needs: [build]
@@ -322,18 +325,23 @@ jobs:
run: yarn build $TURBO_FLAGS
- name: Update CC table # (maybe)
- uses: ./.github/actions/gh-cc-table
+ uses: actions/github-script@v7
with:
- githubToken: ${{ secrets.BOT_TOKEN }}
- env:
- CI: true
+ github-token: ${{secrets.BOT_TOKEN}}
+ result-encoding: string
+ script: |
+ const main = require(`${process.env.GITHUB_WORKSPACE}/.github/action-scripts/updateCCImplementationOverview.js`);
+ return main({github, context});
# ===================
generate-overview:
name: Update toLogEntry overview
# Only run for master branch and don't run in forks
- if: github.repository == 'zwave-js/node-zwave-js' && github.ref == 'refs/heads/master' && github.event_name == 'push'
+ if: |
+ github.repository == 'zwave-js/node-zwave-js' &&
+ github.ref == 'refs/heads/master' &&
+ github.event_name == 'push'
needs: [build]
@@ -360,11 +368,13 @@ jobs:
run: yarn build $TURBO_FLAGS
- name: Update overview
- uses: ./.github/actions/toLogEntry
+ uses: actions/github-script@v7
with:
- githubToken: ${{ secrets.BOT_TOKEN }}
- env:
- CI: true
+ github-token: ${{secrets.BOT_TOKEN}}
+ result-encoding: string
+ script: |
+ const main = require(`${process.env.GITHUB_WORKSPACE}/.github/action-scripts/updateToLogEntryOverview.js`);
+ return main({github, context});
# ===================