mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
NET-5382 & PLAT-1159: Do not trigger workflow if only doc files are in commit history (#18528)
NET-5382: Do not run workflow runs if at least one path matches
This commit is contained in:
parent
b37587bb2c
commit
63fa78a141
33
.github/scripts/filter_changed_files_go_test.sh
vendored
Executable file
33
.github/scripts/filter_changed_files_go_test.sh
vendored
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Get the list of changed files
|
||||||
|
files_to_check=$(git diff --name-only origin/$GITHUB_BASE_REF)
|
||||||
|
|
||||||
|
# Define the directories to check
|
||||||
|
skipped_directories=("docs/" "ui/" "website/" "grafana/")
|
||||||
|
|
||||||
|
# Initialize a variable to track directories outside the skipped ones
|
||||||
|
other_directories=""
|
||||||
|
trigger_ci=false
|
||||||
|
|
||||||
|
# Loop through the changed files and find directories/files outside the skipped ones
|
||||||
|
for file_to_check in $files_to_check; do
|
||||||
|
file_is_skipped=false
|
||||||
|
for dir in "${skipped_directories[@]}"; do
|
||||||
|
if [[ "$file_to_check" == "$dir"* ]] || [[ "$file_to_check" == *.md && "$dir" == *"/" ]]; then
|
||||||
|
file_is_skipped=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$file_is_skipped" = "false" ]; then
|
||||||
|
other_directories+="$(dirname "$file_to_check")\n"
|
||||||
|
trigger_ci=true
|
||||||
|
echo "Non doc file(s) changed - triggered ci: $trigger_ci"
|
||||||
|
echo -e $other_directories
|
||||||
|
echo "trigger-ci=$trigger_ci" >>"$GITHUB_OUTPUT"
|
||||||
|
exit 0 ## if file is outside of the skipped_directory exit script
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Only doc file(s) changed - triggered ci: $trigger_ci"
|
||||||
|
echo "trigger-ci=$trigger_ci" >>"$GITHUB_OUTPUT"
|
18
.github/workflows/go-tests.yml
vendored
18
.github/workflows/go-tests.yml
vendored
@ -24,8 +24,23 @@ env:
|
|||||||
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
|
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
conditional-skip:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Get files changed and conditionally skip CI
|
||||||
|
outputs:
|
||||||
|
trigger-ci: ${{ steps.read-files.outputs.trigger-ci }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Get changed files
|
||||||
|
id: read-files
|
||||||
|
run: ./.github/scripts/filter_changed_files_go_test.sh
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
needs: [conditional-skip]
|
||||||
name: Setup
|
name: Setup
|
||||||
|
if: needs.conditional-skip.outputs.trigger-ci == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
compute-small: ${{ steps.setup-outputs.outputs.compute-small }}
|
compute-small: ${{ steps.setup-outputs.outputs.compute-small }}
|
||||||
@ -464,6 +479,7 @@ jobs:
|
|||||||
|
|
||||||
go-tests-success:
|
go-tests-success:
|
||||||
needs:
|
needs:
|
||||||
|
- conditional-skip
|
||||||
- setup
|
- setup
|
||||||
# Reenable later
|
# Reenable later
|
||||||
#- check-generated-deep-copy
|
#- check-generated-deep-copy
|
||||||
@ -487,7 +503,7 @@ jobs:
|
|||||||
- go-test-32bit
|
- go-test-32bit
|
||||||
# - go-test-s390x
|
# - go-test-s390x
|
||||||
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}
|
||||||
if: ${{ always() }}
|
if: always() && needs.conditional-skip.outputs.trigger-ci == 'true'
|
||||||
steps:
|
steps:
|
||||||
- name: evaluate upstream job results
|
- name: evaluate upstream job results
|
||||||
run: |
|
run: |
|
||||||
|
18
.github/workflows/test-integrations.yml
vendored
18
.github/workflows/test-integrations.yml
vendored
@ -26,9 +26,24 @@ env:
|
|||||||
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
|
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
conditional-skip:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Get files changed and conditionally skip CI
|
||||||
|
outputs:
|
||||||
|
trigger-ci: ${{ steps.read-files.outputs.trigger-ci }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Get changed files
|
||||||
|
id: read-files
|
||||||
|
run: ./.github/scripts/filter_changed_files_go_test.sh
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
needs: [conditional-skip]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Setup
|
name: Setup
|
||||||
|
if: needs.conditional-skip.outputs.trigger-ci == 'true'
|
||||||
outputs:
|
outputs:
|
||||||
compute-small: ${{ steps.runners.outputs.compute-small }}
|
compute-small: ${{ steps.runners.outputs.compute-small }}
|
||||||
compute-medium: ${{ steps.runners.outputs.compute-medium }}
|
compute-medium: ${{ steps.runners.outputs.compute-medium }}
|
||||||
@ -558,6 +573,7 @@ jobs:
|
|||||||
|
|
||||||
test-integrations-success:
|
test-integrations-success:
|
||||||
needs:
|
needs:
|
||||||
|
- conditional-skip
|
||||||
- setup
|
- setup
|
||||||
- dev-build
|
- dev-build
|
||||||
- nomad-integration-test
|
- nomad-integration-test
|
||||||
@ -567,7 +583,7 @@ jobs:
|
|||||||
- compatibility-integration-test
|
- compatibility-integration-test
|
||||||
- peering_commontopo-integration-test
|
- peering_commontopo-integration-test
|
||||||
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}
|
runs-on: ${{ fromJSON(needs.setup.outputs.compute-small) }}
|
||||||
if: ${{ always() }}
|
if: always() && needs.conditional-skip.outputs.trigger-ci == 'true'
|
||||||
steps:
|
steps:
|
||||||
- name: evaluate upstream job results
|
- name: evaluate upstream job results
|
||||||
run: |
|
run: |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user