Skip to content

Commit a2ce628

Browse files
authored
Run affected CI checks for workflow and configuration changes (#3441)
* Run affected CI checks for workflow and configuration changes * Add RSASSA to spellcheck dictionary
1 parent 6e40a85 commit a2ce628

7 files changed

Lines changed: 95 additions & 9 deletions

File tree

‎.github/workflows/build-and-publish-docker-image.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ jobs:
1717
- uses: actions/checkout@v7
1818

1919
- name: 'Login to GitHub Container Registry'
20+
if: github.event_name != 'pull_request'
2021
uses: docker/login-action@v4.7.0
2122
with:
2223
registry: ghcr.io
2324
username: ${{github.actor}}
2425
password: ${{secrets.GITHUB_TOKEN}}
2526

26-
- name: 'Build and publish Docker image'
27+
- name: 'Build Docker image'
2728
run: |
2829
docker build ./docker/ --tag ghcr.io/owasp/asvs/documentbuilder:latest
29-
docker push ghcr.io/owasp/asvs/documentbuilder:latest
30+
31+
- name: 'Publish Docker image'
32+
if: github.event_name != 'pull_request'
33+
run: docker push ghcr.io/owasp/asvs/documentbuilder:latest
3034

‎.github/workflows/build-documents.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,29 @@ jobs:
2222
filters: |
2323
docker:
2424
- 'docker/**/*'
25+
- '.github/workflows/build-documents.yml'
26+
- '.github/workflows/build-and-publish-docker-image.yml'
2527
v5:
2628
- '5.0/**/*'
29+
- 'docker/**/*'
30+
- 'Makefile'
31+
- '.github/workflows/build-documents.yml'
32+
- '.github/workflows/build-and-publish-docker-image.yml'
33+
- '.github/workflows/create-5.0-outputs.yml'
2734
v4:
2835
- '4.0/**/*'
36+
- 'docker/**/*'
37+
- 'Makefile'
38+
- '.github/workflows/build-documents.yml'
39+
- '.github/workflows/build-and-publish-docker-image.yml'
40+
- '.github/workflows/create-4.0-outputs.yml'
2941
outputs:
3042
docker: ${{ steps.filter.outputs.docker }}
3143
v4: ${{ steps.filter.outputs.v4 }}
3244
v5: ${{ steps.filter.outputs.v5 }}
3345

3446
build-image:
35-
if: needs.filters.outputs.docker == 'true'
47+
if: github.event_name != 'pull_request' && needs.filters.outputs.docker == 'true'
3648
needs: filters
3749
uses: ./.github/workflows/build-and-publish-docker-image.yml
3850

@@ -42,13 +54,17 @@ jobs:
4254
- build-image
4355
- filters
4456
uses: ./.github/workflows/create-4.0-outputs.yml
57+
with:
58+
build_local_image: ${{ github.event_name == 'pull_request' && needs.filters.outputs.docker == 'true' }}
4559

4660
build-v5:
4761
if: ${{ always() && needs.filters.outputs.v5 == 'true' }}
4862
needs:
4963
- build-image
5064
- filters
5165
uses: ./.github/workflows/create-5.0-outputs.yml
66+
with:
67+
build_local_image: ${{ github.event_name == 'pull_request' && needs.filters.outputs.docker == 'true' }}
5268

5369
publish-v5-latest:
5470
if: ${{ always() && github.event_name == 'push' && needs.filters.outputs.v5 == 'true' && github.ref == 'refs/heads/master' && (needs.build-v5.result == 'success') }}

‎.github/workflows/config/local-custom.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,4 @@ khalidwalamri
128128
Piotr
129129
Kleszcz
130130
Makna
131+
RSASSA

‎.github/workflows/create-4.0-outputs.yml‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ name: Generate 4.0 Outputs
44
on:
55
# Scan on workflow call
66
workflow_call:
7+
inputs:
8+
build_local_image:
9+
description: Build and use the document builder from this checkout
10+
required: false
11+
default: false
12+
type: boolean
713
# Scan on-demand through GitHub Actions interface:
814
workflow_dispatch: {}
915

@@ -13,12 +19,24 @@ jobs:
1319
name: Generate 4.0 outputs
1420
steps:
1521
- uses: docker/login-action@v4.7.0
22+
if: github.event_name != 'pull_request'
1623
with:
1724
registry: ghcr.io
1825
username: ${{github.actor}}
1926
password: ${{secrets.GITHUB_TOKEN}}
2027
- uses: actions/checkout@v7
21-
- run: make 4.0
28+
- name: Build local document builder
29+
if: inputs.build_local_image
30+
run: docker build ./docker/ --tag ghcr.io/owasp/asvs/documentbuilder:latest
31+
- name: Generate documents
32+
run: |
33+
if [ "$BUILD_LOCAL_IMAGE" = "true" ]; then
34+
make -o docker 4.0
35+
else
36+
make 4.0
37+
fi
38+
env:
39+
BUILD_LOCAL_IMAGE: ${{ inputs.build_local_image }}
2240
- uses: actions/upload-artifact@v7.0.2
2341
with:
2442
name: ASVS 4.0.3

‎.github/workflows/create-5.0-outputs.yml‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
# Scan on workflow call
66
workflow_call:
77
inputs:
8+
build_local_image:
9+
description: Build and use the document builder from this checkout
10+
required: false
11+
default: false
12+
type: boolean
813
languages:
914
description: 'Languages to build (space-separated, e.g., "en tr")'
1015
required: false
@@ -30,13 +35,24 @@ jobs:
3035
name: Generate 5.0 outputs
3136
steps:
3237
- uses: docker/login-action@v4.7.0
38+
if: github.event_name != 'pull_request'
3339
with:
3440
registry: ghcr.io
3541
username: ${{github.actor}}
3642
password: ${{secrets.GITHUB_TOKEN}}
3743
- uses: actions/checkout@v7
38-
- run: make 5.0
44+
- name: Build local document builder
45+
if: inputs.build_local_image
46+
run: docker build ./docker/ --tag ghcr.io/owasp/asvs/documentbuilder:latest
47+
- name: Generate documents
48+
run: |
49+
if [ "$BUILD_LOCAL_IMAGE" = "true" ]; then
50+
make -o docker 5.0
51+
else
52+
make 5.0
53+
fi
3954
env:
55+
BUILD_LOCAL_IMAGE: ${{ inputs.build_local_image }}
4056
LANGS: ${{ inputs.languages || github.event.inputs.languages || 'en' }}
4157
- uses: actions/upload-artifact@v7.0.2
4258
with:

‎.github/workflows/spell-check.yml‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ on:
77
paths:
88
- '**/*.md'
99
- '**/*.markdown'
10+
- '.github/workflows/spell-check.yml'
11+
- '.github/workflows/config/cspell.json'
12+
- '.github/workflows/config/local-custom.txt'
1013
pull_request:
1114
branches:
1215
- master
1316
paths:
1417
- '**/*.md'
1518
- '**/*.markdown'
19+
- '.github/workflows/spell-check.yml'
20+
- '.github/workflows/config/cspell.json'
21+
- '.github/workflows/config/local-custom.txt'
1622
workflow_dispatch:
1723

1824
jobs:
@@ -42,8 +48,18 @@ jobs:
4248
*.md
4349
separator: '\n'
4450

51+
- name: Detect spell-check workflow or configuration changes
52+
if: github.event_name == 'pull_request'
53+
id: config
54+
uses: tj-actions/changed-files@v47
55+
with:
56+
files: |
57+
.github/workflows/spell-check.yml
58+
.github/workflows/config/cspell.json
59+
.github/workflows/config/local-custom.txt
60+
4561
- name: Run cspell on changed files (PR)
46-
if: github.event_name == 'pull_request' && steps.files.outputs.any_changed == 'true'
62+
if: github.event_name == 'pull_request' && steps.config.outputs.any_changed != 'true' && steps.files.outputs.any_changed == 'true'
4763
run: |
4864
# Convert literal '\n' to real newlines for safe file splitting
4965
files_string="${{ steps.files.outputs.all_changed_files }}"
@@ -60,7 +76,7 @@ jobs:
6076
# Run cspell on all changed files; its exit code will control the workflow outcome
6177
cspell --no-must-find-files --config .github/workflows/config/cspell.json "${files[@]}"
6278
63-
- name: Run cspell on all markdown files (push to main or manual)
64-
if: github.event_name != 'pull_request'
79+
- name: Run cspell on all markdown files (workflow/config changes, push or manual)
80+
if: github.event_name != 'pull_request' || steps.config.outputs.any_changed == 'true'
6581
run: |
6682
cspell --config .github/workflows/config/cspell.json "5.0/en/**/*.md" "*.md"

‎.github/workflows/url-checker.yml‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ on:
44
pull_request:
55
paths:
66
- '5.0/**'
7+
- '.github/workflows/url-checker.yml'
8+
- '.github/workflows/config/url-checker-config.json'
79
push:
810
branches:
911
- master
1012
paths:
1113
- '5.0/**'
14+
- '.github/workflows/url-checker.yml'
15+
- '.github/workflows/config/url-checker-config.json'
1216
workflow_dispatch:
1317

1418
jobs:
@@ -23,10 +27,21 @@ jobs:
2327
- name: Install markdown-link-check
2428
run: npm i -g markdown-link-check@3.14.2
2529

30+
- name: Detect URL-checker workflow or configuration changes
31+
if: github.event_name == 'pull_request'
32+
id: config
33+
uses: tj-actions/changed-files@v47
34+
with:
35+
files: |
36+
.github/workflows/url-checker.yml
37+
.github/workflows/config/url-checker-config.json
38+
2639
- name: Determine files to check
2740
id: files
41+
env:
42+
CHECK_ALL: ${{ steps.config.outputs.any_changed }}
2843
run: |
29-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
44+
if [[ "${{ github.event_name }}" == "pull_request" && "$CHECK_ALL" != "true" ]]; then
3045
git diff --name-only --diff-filter=AM origin/${{ github.base_ref }} -- 5.0/ | grep '\.md$' > /tmp/files_to_check.txt || true
3146
echo "mode=modified" >> $GITHUB_OUTPUT
3247
else

0 commit comments

Comments
 (0)