Skip to content

Commit 4917a0e

Browse files
authored
docs only workflow (#5405)
1 parent 3ab4514 commit 4917a0e

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
name: Checks and variables
3838
runs-on: ubuntu-22.04
3939
outputs:
40+
docs_only: ${{ github.event.pull_request && steps.docs.outputs.docs_only == 'true' }}
4041
k8s_latest: ${{ steps.vars.outputs.k8s_latest }}
4142
latest_kindest_node_versions: ${{ steps.vars.outputs.latest_kindest_node_versions }}
4243
go_path: ${{ steps.vars.outputs.go_path }}
@@ -52,6 +53,21 @@ jobs:
5253
steps:
5354
- name: Checkout Repository
5455
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Filter only docs changes
60+
id: docs
61+
run: |
62+
files=$(git diff --name-only HEAD^ | egrep -v "^docs/")
63+
if [ -z "$files" ]; then
64+
echo "docs_only=true" >> $GITHUB_OUTPUT
65+
else
66+
echo "docs_only=false" >> $GITHUB_OUTPUT
67+
fi
68+
echo $files
69+
cat $GITHUB_OUTPUT
70+
shell: bash --noprofile --norc -o pipefail {0}
5571

5672
- name: Setup Golang Environment
5773
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
@@ -241,6 +257,7 @@ jobs:
241257
if: ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
242258

243259
helm-tests:
260+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
244261
name: Helm Tests ${{ matrix.base-os }}
245262
runs-on: ubuntu-22.04
246263
needs: [checks, binaries]
@@ -390,6 +407,7 @@ jobs:
390407
done
391408
392409
setup-matrix:
410+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
393411
name: Setup Matrix for Smoke Tests
394412
runs-on: ubuntu-22.04
395413
needs: [binaries, checks]
@@ -451,6 +469,7 @@ jobs:
451469
if: ${{ steps.check-image.outcome == 'failure' }}
452470

453471
smoke-tests:
472+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
454473
name: ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
455474
runs-on: ubuntu-22.04
456475
needs: [checks, setup-matrix]
@@ -619,6 +638,7 @@ jobs:
619638
fi
620639
621640
build-docker:
641+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
622642
name: Build Docker OSS
623643
needs: [checks, smoke-results]
624644
strategy:
@@ -647,6 +667,7 @@ jobs:
647667
secrets: inherit
648668

649669
build-docker-plus:
670+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
650671
name: Build Docker Plus
651672
needs: [checks, smoke-results, release-notes]
652673
strategy:
@@ -678,6 +699,7 @@ jobs:
678699
secrets: inherit
679700

680701
build-docker-nap:
702+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
681703
name: Build Docker NAP
682704
needs: [checks, smoke-results, release-notes]
683705
strategy:

.github/workflows/codeql-analysis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,33 @@ permissions:
2121
contents: read
2222

2323
jobs:
24+
checks:
25+
name: Checks and variables
26+
runs-on: ubuntu-22.04
27+
outputs:
28+
docs_only: ${{ github.event.pull_request && steps.docs.outputs.docs_only == 'true' }}
29+
steps:
30+
- name: Checkout Repository
31+
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Filter only docs changes
36+
id: docs
37+
run: |
38+
files=$(git diff --name-only HEAD^ | egrep -v "^docs/")
39+
if [ -z "$files" ]; then
40+
echo "docs_only=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "docs_only=false" >> $GITHUB_OUTPUT
43+
fi
44+
echo $files
45+
cat $GITHUB_OUTPUT
46+
shell: bash --noprofile --norc -o pipefail {0}
47+
2448
analyze:
49+
if: ${{ needs.checks.outputs.docs_only != 'true' }}
50+
needs: [checks]
2551
permissions:
2652
actions: read # for github/codeql-action/init to get workflow details
2753
contents: read # for actions/checkout to fetch code

0 commit comments

Comments
 (0)