Skip to content

Commit 1e80022

Browse files
committed
GH Actions: split "validate" workflow
GitHub has the annoying habit of disabling workflows with a cron job after two months if the repo doesn't see any activity. While this won't happen easily for this repo, it may happen in forks 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 (fork) 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 on newly pushed branches.... * ... which means that contributors don't get feedback ahead of creating a PR, increasing the likelyhood the PR will fail CI. Looking at this workflow critically, only the markdown checks should be run via a cron job. All other jobs should only run on push/pull. With that in mind, this commit splits the workflow into two workflows: * One workflow will be triggered via `cron` and will only run the markdown related checks. * One workflow will have all the other triggers (`push`/`pull_request`/`workflow_dispatch`) and will run the full set of validation checks. This way, if the cron job workflow gets disabled, the workflow which is used for the other triggers will continue to function.
1 parent d557e40 commit 1e80022

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Validate Cronjob
2+
3+
on:
4+
# Run this workflow every Monday at 6:00 (to make sure the broken link check runs regularly).
5+
schedule:
6+
- cron: '0 6 * * 1'
7+
8+
# Cancels all previous workflow runs for the same branch that have not yet completed.
9+
concurrency:
10+
# The concurrency group contains the workflow name and the branch name.
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
markdownlint:
16+
name: 'Lint Markdown'
17+
# Don't run the cronjob in this workflow on forks.
18+
if: ${{ github.event.repository.fork == false }}
19+
20+
uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@main
21+
22+
remark:
23+
name: 'QA Markdown'
24+
# Don't run the cronjob in this workflow on forks.
25+
if: ${{ github.event.repository.fork == false }}
26+
27+
uses: PHPCSStandards/.github/.github/workflows/reusable-remark.yml@main

.github/workflows/validate.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
# Run on all pushes and on all pull requests.
55
push:
66
pull_request:
7-
# Also run this workflow every Monday at 6:00 (to make sure the broken link check runs regularly).
8-
schedule:
9-
- cron: '0 6 * * 1'
107
# Allow manually triggering the workflow.
118
workflow_dispatch:
129

@@ -21,9 +18,6 @@ jobs:
2118
name: Check PHP code style
2219
runs-on: ubuntu-latest
2320

24-
# Don't run the cronjob in this workflow on forks.
25-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
26-
2721
steps:
2822
- name: Checkout code
2923
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -47,9 +41,6 @@ jobs:
4741
name: Check XML files
4842
runs-on: ubuntu-latest
4943

50-
# Don't run the cronjob in this workflow on forks.
51-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
52-
5344
steps:
5445
- name: Checkout code
5546
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -91,9 +82,6 @@ jobs:
9182
name: 'XML Code style'
9283
runs-on: ubuntu-latest
9384

94-
# Don't run the cronjob in this workflow on forks.
95-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
96-
9785
env:
9886
XMLLINT_INDENT: ' '
9987

@@ -130,25 +118,16 @@ jobs:
130118
131119
yamllint:
132120
name: 'Lint Yaml'
133-
# Don't run the cronjob in this workflow on forks.
134-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
135-
136121
uses: PHPCSStandards/.github/.github/workflows/reusable-yamllint.yml@main
137122
with:
138123
strict: true
139124

140125
markdownlint:
141126
name: 'Lint Markdown'
142-
# Don't run the cronjob in this workflow on forks.
143-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
144-
145127
uses: PHPCSStandards/.github/.github/workflows/reusable-markdownlint.yml@main
146128

147129
remark:
148130
name: 'QA Markdown'
149-
# Don't run the cronjob in this workflow on forks.
150-
if: ${{ github.event_name != 'schedule' || github.event.repository.fork == false }}
151-
152131
uses: PHPCSStandards/.github/.github/workflows/reusable-remark.yml@main
153132

154133
shellcheck:

0 commit comments

Comments
 (0)