From 3b3c43356992e998db8279a961f6413f54342422 Mon Sep 17 00:00:00 2001 From: Cedric Willekens Date: 2024年4月18日 14:32:13 +0200 Subject: [PATCH 1/2] Fix gha code smells - Avoid deploying from forks --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 66dd346b7ea8c..1cb2e9ce7a3f9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,6 +16,7 @@ permissions: jobs: deploy: runs-on: ubuntu-latest + if: github.repository == 'doocs/leetcode' steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 From a9169c18436e2da9021b4159b25838736479f320 Mon Sep 17 00:00:00 2001 From: Cedric Willekens Date: 2024年4月18日 14:32:13 +0200 Subject: [PATCH 2/2] Fix gha code smells - Avoid deploying from forks - Avoid running CI related actions when no source code has changed - Stop running workflows when there is a newer commit in PR - Stop running workflows when there is a newer commit in branch --- .github/workflows/black-lint.yml | 28 +++++++++++++++++++++++-- .github/workflows/clang-format-lint.yml | 28 +++++++++++++++++++++++-- .github/workflows/compress.yml | 5 +++++ .github/workflows/deploy.yml | 14 +++++++++++++ .github/workflows/pr-add-label.yml | 4 ++++ .github/workflows/pr-checker.yml | 4 ++++ .github/workflows/prettier.yml | 4 ++++ 7 files changed, 83 insertions(+), 4 deletions(-) diff --git a/.github/workflows/black-lint.yml b/.github/workflows/black-lint.yml index 2d386b5426ac0..7d24f5297b2b4 100644 --- a/.github/workflows/black-lint.yml +++ b/.github/workflows/black-lint.yml @@ -1,8 +1,32 @@ name: black-linter on: - push: {} - pull_request: {} + push: + paths: + - package.json + - requirements.txt + - solution/** + - lcs/** + - lcp/** + - lcof2/** + - lcof/** + - lcci/** + - basic/** + pull_request: + paths: + - package.json + - requirements.txt + - solution/** + - lcs/** + - lcp/** + - lcof2/** + - lcof/** + - lcci/** + - basic/** + +concurrency: + group: ${{github.workflow}} - ${{github.ref}} + cancel-in-progress: true jobs: build: diff --git a/.github/workflows/clang-format-lint.yml b/.github/workflows/clang-format-lint.yml index 2f421019e7c15..3893cc9e7e38e 100644 --- a/.github/workflows/clang-format-lint.yml +++ b/.github/workflows/clang-format-lint.yml @@ -1,8 +1,32 @@ name: clang-format-linter on: - push: {} - pull_request: {} + push: + paths: + - package.json + - requirements.txt + - solution/** + - lcs/** + - lcp/** + - lcof2/** + - lcof/** + - lcci/** + - basic/** + pull_request: + paths: + - package.json + - requirements.txt + - solution/** + - lcs/** + - lcp/** + - lcof2/** + - lcof/** + - lcci/** + - basic/** + +concurrency: + group: ${{github.workflow}} - ${{github.ref}} + cancel-in-progress: true jobs: build: diff --git a/.github/workflows/compress.yml b/.github/workflows/compress.yml index d872c074e149b..8e911b5efcafd 100644 --- a/.github/workflows/compress.yml +++ b/.github/workflows/compress.yml @@ -18,6 +18,11 @@ on: workflow_dispatch: schedule: - cron: '00 23 * * 0' + +concurrency: + group: ${{github.workflow}} - ${{github.ref}} + cancel-in-progress: true + jobs: build: name: calibreapp/image-actions diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1cb2e9ce7a3f9..fa53e4e43bb25 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,6 +5,16 @@ on: branches: - main - docs + paths: + - package.json + - requirements.txt + - solution/** + - lcs/** + - lcp/** + - lcof2/** + - lcof/** + - lcci/** + - basic/** workflow_dispatch: env: @@ -13,6 +23,10 @@ env: permissions: contents: write +concurrency: + group: ${{github.workflow}} - ${{github.ref}} + cancel-in-progress: true + jobs: deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/pr-add-label.yml b/.github/workflows/pr-add-label.yml index fc7710799feb9..8059d944a70fb 100644 --- a/.github/workflows/pr-add-label.yml +++ b/.github/workflows/pr-add-label.yml @@ -4,6 +4,10 @@ on: pull_request_target: types: [opened, edited, reopened, synchronize] +concurrency: + group: ${{github.workflow}} - ${{github.event_name}} + cancel-in-progress: true + jobs: add-label: permissions: diff --git a/.github/workflows/pr-checker.yml b/.github/workflows/pr-checker.yml index 7c3219116149e..5d20c141b6931 100644 --- a/.github/workflows/pr-checker.yml +++ b/.github/workflows/pr-checker.yml @@ -4,6 +4,10 @@ on: pull_request_target: types: [opened] +concurrency: + group: ${{github.workflow}} - ${{github.ref}} + cancel-in-progress: true + jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index c426f358b2cdd..3487fa7874225 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -4,6 +4,10 @@ on: pull_request_target: types: [opened, edited, reopened, synchronize] +concurrency: + group: ${{github.workflow}} - ${{github.ref}} + cancel-in-progress: true + jobs: format: permissions:

AltStyle によって変換されたページ (->オリジナル) /