From c4fa5102574afea5b0e94338e7a6e1db538a9597 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Tue, 23 Jan 2024 10:12:13 +0800 Subject: [PATCH] ci: Add postCommit workflow dispatch --- .github/workflows/generatePolyfill.yaml | 2 ++ scripts/postCommit/push.js | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generatePolyfill.yaml b/.github/workflows/generatePolyfill.yaml index 639f5898..d469d035 100644 --- a/.github/workflows/generatePolyfill.yaml +++ b/.github/workflows/generatePolyfill.yaml @@ -89,3 +89,5 @@ jobs: - name: Show git status & push id: output run: node scripts/postCommit/push.js + env: + DISPATCH_POST_COMMIT_WORKFLOW: true diff --git a/scripts/postCommit/push.js b/scripts/postCommit/push.js index 1fb61979..95c21257 100644 --- a/scripts/postCommit/push.js +++ b/scripts/postCommit/push.js @@ -2,7 +2,7 @@ import console from "../modules/console.js"; console.info("Initialization done."); import { startGroup, endGroup } from "@actions/core"; import git from "../modules/git.js"; -import { isInGithubActions } from "../modules/octokit.js"; +import { isInGithubActions, octokit } from "../modules/octokit.js"; import readWorkflowEvent from "../modules/workflowEvent.js"; import upstream from "../modules/getUpstream.js"; if (!isInGithubActions) { @@ -37,3 +37,10 @@ console.info("Pulling new commits..."); console.info("Successfully pulled the commits:", await git.pull(undefined, undefined, ["--rebase"])); console.info("Pushing these commits..."); console.info("Successfully pushed the commits:", await git.push()); +if (process.env.DISPATCH_POST_COMMIT_WORKFLOW === "true") { + console.info("Dispatching postCommit workflow..."); + await octokit.rest.actions.createWorkflowDispatch({ + workflow_id: ".github/workflows/postCommit.yaml", + ref: upstream, + }); +}