Skip to content

Commit a2b0561

Browse files
authored
[ci] Make build a reuseable workflow (#272)
This should avoid triggering unnecessary publish-* workflows, as we can now filter on the events beforehand. The additional filter is still kept for additional safety. Refs pmd/pmd#4328
1 parent 5ec029a commit a2b0561

File tree

6 files changed

+43
-15
lines changed

6 files changed

+43
-15
lines changed

.github/workflows/build-pr.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Build Pull Request
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
types: [checks_requested]
7+
8+
jobs:
9+
build:
10+
name: Build Pull Request
11+
uses: ./.github/workflows/build.yml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Build Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build Release
12+
uses: ./.github/workflows/build.yml
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build Snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
# don't run on dependabot branches. Dependabot will create pull requests, which will then be run instead
8+
- '!dependabot/**'
9+
workflow_dispatch:
10+
schedule:
11+
# build it monthly: At 05:00 on day-of-month 1.
12+
- cron: '0 5 1 * *'
13+
14+
jobs:
15+
build:
16+
name: Build Snapshot
17+
uses: ./.github/workflows/build.yml

.github/workflows/build.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
name: Build
22

33
on:
4-
pull_request:
5-
merge_group:
6-
push:
7-
branches:
8-
- '**'
9-
# don't run on dependabot branches. Dependabot will create pull requests, which will then be run instead
10-
- '!dependabot/**'
11-
tags:
12-
- '**'
13-
workflow_dispatch:
14-
schedule:
15-
# build it monthly: At 05:00 on day-of-month 1.
16-
- cron: '0 5 1 * *'
4+
workflow_call:
175

186
# if another commit is added to the same branch or PR (same github.ref),
197
# then cancel already running jobs and start a new build.

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish Release
22

33
on:
44
workflow_run:
5-
workflows: [Build]
5+
workflows: [Build Release]
66
types:
77
- completed
88
branches:

.github/workflows/publish-snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Publish Snapshot
22

33
on:
44
workflow_run:
5-
workflows: [Build]
5+
workflows: [Build Snapshot]
66
types:
77
- completed
88
branches:

0 commit comments

Comments
 (0)