Skip to content

Commit

Permalink
Update workflows to use "concurrency" GHA functionality to skip
Browse files Browse the repository at this point in the history
redundant workflow runs.
  • Loading branch information
tomaz-s1 committed Sep 29, 2023
1 parent d6ca111 commit 2dedaf6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
23 changes: 6 additions & 17 deletions .github/workflows/check-code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,17 @@ on:
- cron: '0 4 * * *'

permissions:
actions: write # Needed for skip-duplicate-jobs job
contents: read

jobs:
# Special job which automatically cancels old runs for the same branch, prevents runs for the
# same file set which has already passed, etc.
pre_job:
name: Skip Duplicate Jobs Pre Job
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@12aca0a884f6137d619d6a8a09fcc3406ced5281 # v5.3.0
with:
cancel_others: 'true'
github_token: ${{ github.token }}
# We don't want to cancel any redundant runs on main so we use run_id when head_ref is
# not available
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'main' }}

steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ on:
schedule:
- cron: '15 9 * * 5'

permissions:
contents: read

# We don't want to cancel any redundant runs on main so we use run_id when head_ref is
# not available
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
analyze:
name: Analyze
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
name: Playwright E2E Tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read

# We don't want to cancel any redundant runs on main so we use run_id when head_ref is
# not available
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
timeout-minutes: 30
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on: [pull_request]
permissions:
contents: read

# We don't want to cancel any redundant runs on main so we use run_id when head_ref is
# not available
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
UnitTest:
runs-on: ubuntu-latest
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on: [pull_request]
permissions:
contents: read

# We don't want to cancel any redundant runs on main so we use run_id when head_ref is
# not available
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
validate:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 2dedaf6

Please sign in to comment.