Skip to content

Commit 4852ada

Browse files
committed
Optimize workflow triggers and add concurrency auto-cancel
1 parent 0134e2d commit 4852ada

3 files changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ name: integration_tests
22

33
on:
44
pull_request:
5+
paths-ignore:
6+
- README.md
57
push:
68
branches:
79
- main
10+
paths-ignore:
11+
- README.md
12+
13+
concurrency:
14+
group: integration-tests-${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
816

917
jobs:
1018
backup_restore_matrix:

.github/workflows/main.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,33 @@ name: build_image
22

33
on:
44
push:
5-
branches:
6-
- main
75
tags:
86
- "*"
9-
paths:
10-
- "**"
11-
- "!README.md"
7+
workflow_run:
8+
workflows:
9+
- integration_tests
10+
types:
11+
- completed
1212

1313
permissions:
1414
contents: read
1515
packages: write
1616

17+
concurrency:
18+
group: build-image-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref || github.event.workflow_run.head_branch || github.run_id }}
19+
cancel-in-progress: true
20+
1721
jobs:
1822
build:
23+
if: |
24+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||
25+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main')
1926
runs-on: ubuntu-latest
2027
steps:
2128
- name: Checkout
2229
uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
2332

2433
- name: Set up QEMU
2534
uses: docker/setup-qemu-action@v3
@@ -40,8 +49,7 @@ jobs:
4049
with:
4150
images: ghcr.io/${{ github.repository }}
4251
tags: |
43-
type=raw,value=latest,enable={{is_default_branch}}
44-
type=ref,event=branch
52+
type=raw,value=latest,enable=${{ github.event_name == 'workflow_run' }}
4553
type=ref,event=tag
4654
type=sha
4755

.github/workflows/manual.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ permissions:
77
contents: read
88
packages: write
99

10+
concurrency:
11+
group: manual-build-${{ github.workflow }}-${{ github.ref || github.run_id }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
build:
1216
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)