Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: migrate implementation status overview to github-script #6735

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Updates the CC implementation status table in issue 6

// @ts-check
/// <reference path="../bot-scripts/types.d.ts" />

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 = {};
Expand All @@ -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;
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Updates the toLogEntry implementation status table in issue 54

// @ts-check
/// <reference path="../bot-scripts/types.d.ts" />

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} */
Expand All @@ -23,19 +29,19 @@ 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:

${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",
Expand All @@ -44,4 +50,5 @@ ${result}`;
} else {
console.error(c.yellow("No changes to the implementation status!"));
}
})();
}
module.exports = main;
10 changes: 0 additions & 10 deletions .github/actions/gh-cc-table/action.yml

This file was deleted.

10 changes: 0 additions & 10 deletions .github/actions/toLogEntry/action.yml

This file was deleted.

30 changes: 20 additions & 10 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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]

Expand All @@ -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});

# ===================

Expand Down
Loading