Skip to content

Commit 9d1470d

Browse files
committed
GH Actions: split workflow
GitHub has the annoying habit of disabling workflows with a cron job after two months if the repo doesn't see any activity. This is regularly the case for this repo and this creates the following problem: * If the same workflow is used for both the cron job as well as the push/pull_request CI checks... * ... and a repo doesn't have any activity in two months time... * ... the workflow gets disabled... * ... which then also means that CI checks will no longer be run for new PRs.... * ... which means new PRs can't be merged as (in most cases) the repo has branch protection in place and requires that the CI checks pass before a PR can be merged. This commit basically changes the original workflow to a reusable workflow and then creates two new workflows, with different `on` targets, which each trigger the reusable workflow. * One workflow will be triggered via `cron`. * One workflow will have all the other triggers (`push`/`pull_request`/`workflow_dispatch`). This way, if the cron job workflow gets disabled, the workflow which is used for the other triggers will continue to function. The downside of this, is that it may go unnoticed that the cron job has stopped running, but so be it.
1 parent 49b0e8d commit 9d1470d

File tree

3 files changed

+51
-32
lines changed

3 files changed

+51
-32
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Validate
2+
3+
on:
4+
workflow_call:
5+
6+
permissions: {}
7+
8+
jobs:
9+
validate:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
php: ['5.4', 'latest']
16+
17+
name: PHP ${{ matrix.php }}
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22+
with:
23+
persist-credentials: false
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
27+
with:
28+
php-version: ${{ matrix.php }}
29+
coverage: none
30+
31+
- name: Install dependencies
32+
run: composer update --no-interaction --no-progress
33+
34+
- name: Validate Composer installation
35+
run: composer validate --no-check-all --strict
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Validate Cronjob
2+
3+
on:
4+
# Run the validation workflow on day 15 of every month as the repo isn't that active.
5+
schedule:
6+
- cron: '0 0 15 * *'
7+
8+
permissions: {}
9+
10+
jobs:
11+
validate:
12+
# Don't run the cron job on forks.
13+
if: ${{ github.event.repository.fork == false }}
14+
15+
uses: ./.github/workflows/reusable-validate.yml

.github/workflows/validate.yml

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,11 @@ on:
44
# Run on all pushes and pull requests.
55
push:
66
pull_request:
7-
# Also run this workflow on day 15 of every month as the repo isn't that active.
8-
schedule:
9-
- cron: '0 0 15 * *'
107
# Allow manually triggering the workflow.
118
workflow_dispatch:
129

1310
permissions: {}
1411

1512
jobs:
1613
validate:
17-
# Don't run the cron job on forks.
18-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
19-
20-
runs-on: ubuntu-latest
21-
22-
strategy:
23-
fail-fast: true
24-
matrix:
25-
php: ['5.4', 'latest']
26-
27-
name: PHP ${{ matrix.php }}
28-
29-
steps:
30-
- name: Checkout code
31-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
32-
with:
33-
persist-credentials: false
34-
35-
- name: Install PHP
36-
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
37-
with:
38-
php-version: ${{ matrix.php }}
39-
coverage: none
40-
41-
- name: Install dependencies
42-
run: composer update --no-interaction --no-progress
43-
44-
- name: Validate Composer installation
45-
run: composer validate --no-check-all --strict
14+
uses: ./.github/workflows/reusable-validate.yml

0 commit comments

Comments
 (0)