-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add type checking to github scripts (#9851)
## Summary - Add [`actions/github-script`](https://github.com/marketplace/actions/github-script) types - Add [`@octokit/webhook-types`](https://www.npmjs.com/package/@octokit/webhooks-types) for improved payload typing - Use JSDoc wizardry to typecheck the JavaScript files used by our workflows ## Notes I got a husky error when installing the `github-script` types. Here is a related issue: typicode/husky#851 Upgrading husky resolves the error, so I created a pull request: actions/github-script#482 I installed `github-script` using the PR number for now. We can unpin the PR once it's merged by re-installing via the [command in the doc](https://github.com/actions/github-script/#use-scripts-with-jsdoc-support): ```sh npm i -D @types/github-script@github:actions/github-script ```
- Loading branch information
Showing
13 changed files
with
607 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
// @ts-check | ||
// If the "new component" label is added to an issue, generates a notification to the Calcite designer lead(s) | ||
// The secret is formatted like so: designer1, designer2, designer3 | ||
// Note the script automatically adds the "@" character in to notify the designer lead(s) | ||
|
||
/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */ | ||
module.exports = async ({ github, context }) => { | ||
const { designers } = process.env; | ||
const { repo, owner } = context.repo; | ||
|
||
const payload = /** @type {import('@octokit/webhooks-types').IssuesLabeledEvent} */ (context.payload); | ||
const { | ||
issue: { number }, | ||
} = payload; | ||
|
||
const { DESIGNERS } = process.env; | ||
|
||
// Add a "@" character to notify the user | ||
const calcite_designers = designers.split(",").map((v) => " @" + v.trim()); | ||
const calcite_designers = DESIGNERS?.split(",").map((v) => " @" + v.trim()); | ||
|
||
if (!calcite_designers?.length) { | ||
console.error("unable to determine designers"); | ||
process.exit(1); | ||
} | ||
|
||
// Add a comment to issues with the 'new component' label to notify the designer(s) | ||
await github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
owner, | ||
repo, | ||
issue_number: number, | ||
body: `cc ${calcite_designers}`, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.