From 778ea71eb37010a24dae9856475b4196dd3d30ff Mon Sep 17 00:00:00 2001 From: octodog Date: Tue, 17 Dec 2024 18:02:41 +0900 Subject: [PATCH] ci: Remove labeled triggers for skip:ci (#3122) (#3264) Co-authored-by: Sion Kang Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 11 +++++++---- .github/workflows/skip-ci.yml | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/skip-ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48dbebba3f..2c79f14f50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: tags: - '[0-9][0-9].0[39].*' pull_request: - types: [labeled, unlabeled, opened, synchronize, reopened] + types: [opened, synchronize, reopened] merge_group: concurrency: @@ -77,7 +77,8 @@ jobs: lint: if: | !( - contains(github.event.pull_request.labels.*.name, 'skip:ci') + contains(toJSON(github.event.commits.*.msg), 'skip:ci') + || contains(github.event.pull_request.labels.*.name, 'skip:ci') || needs.optimize-ci.outputs.skip == 'true' ) && !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name) @@ -182,7 +183,8 @@ jobs: typecheck: if: | !( - contains(github.event.pull_request.labels.*.name, 'skip:ci') + contains(toJSON(github.event.commits.*.msg), 'skip:ci') + || contains(github.event.pull_request.labels.*.name, 'skip:ci') || needs.optimize-ci.outputs.skip == 'true' ) && !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name) @@ -254,7 +256,8 @@ jobs: test: if: | !( - contains(github.event.pull_request.labels.*.name, 'skip:ci') + contains(toJSON(github.event.commits.*.msg), 'skip:ci') + || contains(github.event.pull_request.labels.*.name, 'skip:ci') || needs.optimize-ci.outputs.skip == 'true' ) && !contains(fromJSON('["flow:merge-queue", "flow:hotfix"]'), github.event.label.name) diff --git a/.github/workflows/skip-ci.yml b/.github/workflows/skip-ci.yml new file mode 100644 index 0000000000..2fb491570e --- /dev/null +++ b/.github/workflows/skip-ci.yml @@ -0,0 +1,33 @@ +name: skip-ci + +on: + pull_request: + types: [labeled, unlabeled] + +jobs: + skip_ci: + if: contains(github.event.pull_request.labels.*.name, 'skip:ci') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + token: ${{ secrets.OCTODOG }} + - name: Skip CI + if: github.event.action == 'labeled' + run: + git config --global user.email "mu001@lablup.com" + git config --global user.name "octodog" + git commit --allow-empty -m "skip:ci" + git push + - name: Revoke skip:ci + if: github.event.action == 'unlabeled' + run: + git config --global user.email "mu001@lablup.com" + git config --global user.name "octodog" + previous_commit_message=$(git log -n 1 --pretty=format:%s --skip 1) + if [[ "$previous_commit_message" == "skip:ci" ]]; then + git log -n 1 --pretty=format:%H --skip 1 | xargs git revert --no-edit + git push + fi