From 36fcb6d46120b9b5cadf7b9537ab7e920c0d70be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Sun, 27 Feb 2022 14:44:26 +0900 Subject: [PATCH] chore: Skip CI for automated commits (#3760) * Use only title * skip * skip --- .github/workflows/cargo.yml | 2 ++ .github/workflows/docs.yml | 2 ++ scripts/bot/src/auto-rebase.ts | 4 ++-- scripts/bot/src/cargo/bump.ts | 4 ++-- scripts/bot/src/util/git.ts | 6 ++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cargo.yml b/.github/workflows/cargo.yml index fb16312a9dea..2a5056d298e9 100644 --- a/.github/workflows/cargo.yml +++ b/.github/workflows/cargo.yml @@ -75,6 +75,8 @@ jobs: test: name: Test - ${{ matrix.settings.crate }} - ${{ matrix.settings.os }} runs-on: ${{ matrix.settings.os }} + if: >- + ${{ !contains(github.event.head_commit.message, 'chore: ') }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f33dbf994714..423a7c47a940 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -10,6 +10,8 @@ jobs: name: Rustdoc concurrency: swc-docs-rustdoc runs-on: macos-latest + if: >- + ${{ !contains(github.event.head_commit.message, 'chore: ') }} steps: - uses: actions/checkout@v2 diff --git a/scripts/bot/src/auto-rebase.ts b/scripts/bot/src/auto-rebase.ts index 50442df56f49..9aca22a68983 100644 --- a/scripts/bot/src/auto-rebase.ts +++ b/scripts/bot/src/auto-rebase.ts @@ -1,4 +1,4 @@ -import { getLatestCommitMesssage } from "./util/git"; +import { getTitleOfLatestCommit } from "./util/git"; import { octokit } from "./util/octokit"; // We only auto-rebase if the latest commit message is one of @@ -10,7 +10,7 @@ const owner = 'swc-project'; const repo = 'swc'; (async () => { - const latestCommitMessage = await getLatestCommitMesssage(); + const latestCommitMessage = await getTitleOfLatestCommit(); console.log(`Latest commit message: ${latestCommitMessage}`); diff --git a/scripts/bot/src/cargo/bump.ts b/scripts/bot/src/cargo/bump.ts index 058526a824db..40315506bf2c 100644 --- a/scripts/bot/src/cargo/bump.ts +++ b/scripts/bot/src/cargo/bump.ts @@ -1,10 +1,10 @@ import { exec } from "child_process"; -import { getLatestCommitMesssage } from "../util/git"; +import { getTitleOfLatestCommit } from "../util/git"; import { parsePrComments } from "./comment-parser"; (async () => { - const latestCommitMessage = await getLatestCommitMesssage(); + const latestCommitMessage = await getTitleOfLatestCommit(); console.log('Latest commit message:', latestCommitMessage); const lParenIndex = latestCommitMessage.lastIndexOf('(#'); diff --git a/scripts/bot/src/util/git.ts b/scripts/bot/src/util/git.ts index 0219e83f0811..492c9e65626d 100644 --- a/scripts/bot/src/util/git.ts +++ b/scripts/bot/src/util/git.ts @@ -12,10 +12,12 @@ async function streamToString(stream: Stream): Promise { -export async function getLatestCommitMesssage(): Promise { +export async function getTitleOfLatestCommit(): Promise { const { stdout } = await exec('git log -1 --pretty=%B'); const msg = await streamToString(stdout!); - return msg.trim() + const s = msg.trim(); + + return s.split('\n')[0] } \ No newline at end of file