aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/commentCodeGeneration.ts
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-11-09 11:14:08 +0100
committerGitHub <[email protected]>2024-11-09 11:14:08 +0100
commit519d212faec4ac4269693f060d7f8ff5e3dab94c (patch)
tree0aff8ef843ee5ad510ca5ee4e93ac477a52c9e40 /.github/workflows/commentCodeGeneration.ts
parent525fedc91bd02f53330cfb40fe228b148dcf562b (diff)
downloadfaker-519d212faec4ac4269693f060d7f8ff5e3dab94c.tar.xz
faker-519d212faec4ac4269693f060d7f8ff5e3dab94c.zip
infra: remove preflight failure comment (#3188)
Diffstat (limited to '.github/workflows/commentCodeGeneration.ts')
-rw-r--r--.github/workflows/commentCodeGeneration.ts73
1 files changed, 0 insertions, 73 deletions
diff --git a/.github/workflows/commentCodeGeneration.ts b/.github/workflows/commentCodeGeneration.ts
deleted file mode 100644
index 2e8a115c..00000000
--- a/.github/workflows/commentCodeGeneration.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import type { context as ctx, GitHub } from '@actions/github/lib/utils';
-
-/**
- * Notifies the PR about uncommitted changes generated by the `generate:*` commands.
- *
- * This script is used by github-script
- * https://github.com/actions/github-script
- *
- * @param github A pre-authenticated octokit/rest.js client with pagination plugins
- * @param context An object containing the context of the workflow run.
- */
-export async function script(
- github: InstanceType<typeof GitHub>,
- context: typeof ctx
-): Promise<void> {
- const repoArgs = { owner: context.repo.owner, repo: context.repo.repo };
-
- // Identify the PR that triggered the workflow
- const head_branch: string = context.payload.workflow_run.head_branch;
- const { data: prs } = await github.rest.pulls.list({
- ...repoArgs,
- state: 'open',
- head: head_branch,
- });
-
- if (prs.length === 0) {
- console.log(`No PRs found for branch ${head_branch}`);
- return;
- }
-
- const pr_number = prs[0].number;
-
- // Check if the PR already has a comment from the bot
-
- const { data: comments } = await github.rest.issues.listComments({
- ...repoArgs,
- issue_number: pr_number,
- });
-
- const body = `GitHub Actions has found some problems running the preflight checks.
-
-Please make sure to:
-
-- run \`pnpm run preflight\` locally
-- fix all issues until the command completes without errors
-- commit and push the changes
-`;
-
- const botComment = comments.find(
- (comment) => comment.user?.type === 'Bot' && comment.body?.includes(body)
- );
-
- const isSuccess = context.payload.workflow_run.conclusion === 'success';
-
- if (isSuccess) {
- // Delete the bot comment if present
- if (botComment != null) {
- await github.rest.issues.deleteComment({
- ...repoArgs,
- comment_id: botComment.id,
- });
- }
- } else {
- // Create the comment if missing
- if (botComment == null) {
- await github.rest.issues.createComment({
- ...repoArgs,
- issue_number: pr_number,
- body,
- });
- }
- }
-}