Skip to content

Commit 07266cd

Browse files
authored
[ci] Make build a reuseable workflow (#70)
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 72a09f8 commit 07266cd

File tree

6 files changed

+45
-17
lines changed

6 files changed

+45
-17
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 04:15 on day-of-month 1.
12+
- cron: '15 4 1 * *'
13+
# for testing the event "schedule": run every 15 minutes starting from minute 5 through 59 (0, 15, 30, 45)
14+
#- cron: '0/15 * * * *'
15+
16+
jobs:
17+
build:
18+
name: Build Snapshot
19+
uses: ./.github/workflows/build.yml

.github/workflows/build.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +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 04:15 on day-of-month 1.
16-
- cron: '15 4 1 * *'
17-
# for testing the event "schedule": run every 15 minutes starting from minute 5 through 59 (0, 15, 30, 45)
18-
#- cron: '0/15 * * * *'
4+
workflow_call:
195

206
# if another commit is added to the same branch or PR (same github.ref),
217
# 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)