Skip to content

Commit

Permalink
chore(deps): update actions/github-script action to v5 (zwave-js#3724)
Browse files Browse the repository at this point in the history
* chore(deps): update actions/github-script action to v5

* fix(ci): github.xyz -> github.rest.xyz

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Dominic Griesel <d.griesel@gmx.net>
  • Loading branch information
3 people authored Nov 15, 2021
1 parent 0dfcdee commit 25ebc56
Show file tree
Hide file tree
Showing 18 changed files with 100 additions and 102 deletions.
16 changes: 4 additions & 12 deletions .github/bot-scripts/addCompatFlag.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
// @ts-check

/// <reference path="types.d.ts" />

// To require non-local modules, we need to setup Yarn PnP
// @ts-ignore
require("../../.pnp.cjs").setup();

const { ConfigManager } = require("@zwave-js/config");
const JSONC = require("comment-json");
const fs = require("fs-extra");
const prettier = require("prettier");

function formatWithPrettier(filename, sourceText) {
const prettierOptions = {
...require("../../.prettierrc"),
// To infer the correct parser
filepath: filename,
};
return prettier.format(sourceText, prettierOptions);
}

// @ts-check
const { formatWithPrettier } = require("./utils");

/**
* @param {{github: Github, context: Context}} param
Expand Down
14 changes: 7 additions & 7 deletions .github/bot-scripts/addCompatFlagCreatePR.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

/// <reference path="types.d.ts" />

const { reviewers } = require("./users");

// @ts-check

/**
* @param {{github: Github, context: Context}} param
*/
Expand All @@ -16,15 +16,15 @@ async function main(param) {
};

if (process.env.RESULT === "unchanged") {
await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `❌ Sorry, adding the compat flag(s) yielded no changes.`,
});
return;
}

const pr = await github.pulls.create({
const pr = await github.rest.pulls.create({
...options,
head: process.env.branchname,
base: "master",
Expand All @@ -38,18 +38,18 @@ async function main(param) {
const prNumber = pr.data.number;

// Request review and add assignee
await github.pulls.requestReviewers({
await github.rest.pulls.requestReviewers({
...options,
pull_number: prNumber,
reviewers: reviewers.config,
});
await github.issues.addAssignees({
await github.rest.issues.addAssignees({
...options,
issue_number: prNumber,
assignees: reviewers.config,
});

await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `🔨 I created a PR at #${prNumber} - check it out!`,
Expand Down
16 changes: 4 additions & 12 deletions .github/bot-scripts/addFingerprint.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
// @ts-check

/// <reference path="types.d.ts" />

// To require non-local modules, we need to setup Yarn PnP
// @ts-ignore
require("../../.pnp.cjs").setup();

const { ConfigManager } = require("@zwave-js/config");
const { formatId } = require("@zwave-js/shared");
const JSONC = require("comment-json");
const fs = require("fs-extra");
const prettier = require("prettier");

function formatWithPrettier(filename, sourceText) {
const prettierOptions = {
...require("../../.prettierrc"),
// To infer the correct parser
filepath: filename,
};
return prettier.format(sourceText, prettierOptions);
}

// @ts-check
const { formatWithPrettier } = require("./utils");

/**
* @param {{github: Github, context: Context}} param
Expand Down
14 changes: 7 additions & 7 deletions .github/bot-scripts/addFingerprintCreatePR.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

/// <reference path="types.d.ts" />

const { reviewers } = require("./users");

// @ts-check

/**
* @param {{github: Github, context: Context}} param
*/
Expand All @@ -16,15 +16,15 @@ async function main(param) {
};

if (process.env.RESULT === "unchanged") {
await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `❌ Sorry, adding the fingerprint yielded no changes.`,
});
return;
}

const pr = await github.pulls.create({
const pr = await github.rest.pulls.create({
...options,
head: process.env.branchname,
base: "master",
Expand All @@ -35,18 +35,18 @@ async function main(param) {
const prNumber = pr.data.number;

// Request review and add assignee
await github.pulls.requestReviewers({
await github.rest.pulls.requestReviewers({
...options,
pull_number: prNumber,
reviewers: reviewers.config,
});
await github.issues.addAssignees({
await github.rest.issues.addAssignees({
...options,
issue_number: prNumber,
assignees: reviewers.config,
});

await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `🔨 I created a PR at #${prNumber} - check it out!`,
Expand Down
13 changes: 7 additions & 6 deletions .github/bot-scripts/approveWorkflows.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// @ts-check

// To require non-local modules, we need to setup Yarn PnP
// @ts-ignore
require("../../.pnp.cjs").setup();

const { makeRe } = require("minimatch");

/// <reference path="./types.d.ts" />

// @ts-check

/**
* @param {{github: Github, context: Context, whitelist: string[], workflows: string[]}} param
*/
Expand All @@ -21,7 +22,7 @@ async function main(param) {
// Figure out which workflow IDs the whitelisted workflows have
const {
data: { workflows: repoWorkflows },
} = await github.actions.listRepoWorkflows({
} = await github.rest.actions.listRepoWorkflows({
...options,
});
const workflowIDs = repoWorkflows
Expand All @@ -31,7 +32,7 @@ async function main(param) {
// Only look at the runs that part of the whitelisted workflows
const {
data: { workflow_runs },
} = await github.actions.listWorkflowRunsForRepo({
} = await github.rest.actions.listWorkflowRunsForRepo({
...options,
status: "action_required",
});
Expand All @@ -45,7 +46,7 @@ async function main(param) {
console.log(`Checking run ${run.id}...`);

// Find the pull request for the current run
const { data: pulls } = await github.pulls.list({
const { data: pulls } = await github.rest.pulls.list({
...options,
head: `${run.head_repository.owner.login}:${run.head_branch}`,
});
Expand All @@ -58,7 +59,7 @@ async function main(param) {
}

// List all the files in there
const { data: files } = await github.pulls.listFiles({
const { data: files } = await github.rest.pulls.listFiles({
...options,
pull_number: pulls[0].number,
});
Expand Down
8 changes: 4 additions & 4 deletions .github/bot-scripts/checkAuthorized.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="types.d.ts" />
// @ts-check
/// <reference path="types.d.ts" />

const { authorizedUsers } = require("./users");

Expand All @@ -22,7 +22,7 @@ async function main(param) {
if (context.payload.issue.html_url.includes("/pull/")) {
console.log("Comment appears in a PR, retrieving PR info...");
// Only the pull request author and authorized users may execute this command
const { data: pull } = await github.pulls.get({
const { data: pull } = await github.rest.pulls.get({
...options,
pull_number: context.payload.issue.number,
});
Expand All @@ -44,14 +44,14 @@ async function main(param) {

if (isAuthorized) {
// Let the user know we're working on it
await github.reactions.createForIssueComment({
await github.rest.reactions.createForIssueComment({
...options,
comment_id: context.payload.comment.id,
content: "rocket",
});
} else {
// Let the user know he can't do that
await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `Sorry ${user}, you're not authorized to do that 🙁!`,
Expand Down
4 changes: 2 additions & 2 deletions .github/bot-scripts/fixLintFeedback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="types.d.ts" />
// @ts-check
/// <reference path="types.d.ts" />

/**
* @param {{github: Github, context: Context}} param
Expand All @@ -23,7 +23,7 @@ async function main(param) {
return;
}

await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: feedbackText,
Expand Down
12 changes: 6 additions & 6 deletions .github/bot-scripts/getFixLintInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="types.d.ts" />
// @ts-check
/// <reference path="types.d.ts" />

/**
* @param {{github: Github, context: Context}} param
Expand All @@ -13,11 +13,11 @@ async function main(param) {
};

// Get PR info
const { data: pull } = await github.pulls.get({
const { data: pull } = await github.rest.pulls.get({
...options,
pull_number: context.issue.number,
});
const { data: checks } = await github.checks.listForRef({
const { data: checks } = await github.rest.checks.listForRef({
...options,
ref: pull.head.sha,
});
Expand All @@ -27,20 +27,20 @@ async function main(param) {
);
if (!lintCheck) return undefined;

const { data: job } = await github.actions.getJobForWorkflowRun({
const { data: job } = await github.rest.actions.getJobForWorkflowRun({
...options,
job_id: lintCheck.id,
});
const {
data: { artifacts },
} = await github.actions.listWorkflowRunArtifacts({
} = await github.rest.actions.listWorkflowRunArtifacts({
...options,
run_id: job.run_id,
});

if (!artifacts.length) return undefined;

const { url } = await github.actions.downloadArtifact({
const { url } = await github.rest.actions.downloadArtifact({
...options,
artifact_id: artifacts[0].id,
archive_format: "zip",
Expand Down
13 changes: 6 additions & 7 deletions .github/bot-scripts/importConfigCreatePR.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// @ts-check
/// <reference path="types.d.ts" />

const { reviewers } = require("./users");

// @ts-check

/**
* @param {{github: Github, context: Context}} param
*/
Expand All @@ -16,15 +15,15 @@ async function main(param) {
};

if (process.env.RESULT === "unchanged") {
await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `❌ Sorry, importing the files yielded no changes.`,
});
return;
}

const pr = await github.pulls.create({
const pr = await github.rest.pulls.create({
...options,
head: process.env.branchname,
base: "master",
Expand All @@ -38,18 +37,18 @@ async function main(param) {
const prNumber = pr.data.number;

// Request review and add assignee
await github.pulls.requestReviewers({
await github.rest.pulls.requestReviewers({
...options,
pull_number: prNumber,
reviewers: reviewers.config,
});
await github.issues.addAssignees({
await github.rest.issues.addAssignees({
...options,
issue_number: prNumber,
assignees: reviewers.config,
});

await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `🔨 I created a PR at #${prNumber} - check it out!`,
Expand Down
4 changes: 2 additions & 2 deletions .github/bot-scripts/rebaseFeedback.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="types.d.ts" />
// @ts-check
/// <reference path="types.d.ts" />

/**
* @param {{github: Github, context: Context}} param
Expand All @@ -19,7 +19,7 @@ async function main(param) {
return;
}

await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: feedbackText,
Expand Down
6 changes: 3 additions & 3 deletions .github/bot-scripts/renameCommitCheck.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="types.d.ts" />
// @ts-check
/// <reference path="types.d.ts" />

/**
* @param {{github: Github, context: Context}} param
Expand All @@ -16,14 +16,14 @@ async function main(param) {
...options,
pull_number: context.issue.number,
};
const { data: commits } = await github.pulls.listCommits({
const { data: commits } = await github.rest.pulls.listCommits({
...options,
pull_number: context.issue.number,
});

if (commits.length > 1) {
// Not necessary to do this.
await github.issues.createComment({
await github.rest.issues.createComment({
...options,
issue_number: context.payload.issue.number,
body: `There is more than one commit - no need to rename it.`,
Expand Down
Loading

0 comments on commit 25ebc56

Please sign in to comment.