-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QT-517] Skip builds for docs PRs (#20036)
* [QT-517] Skip builds for docs changes Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com> * [QT-545] Enable Enos tests to also run on forked PRs Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com> * Add comments and fix CI errors Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com> --------- Signed-off-by: Jaymala Sinha <jaymala@hashicorp.com>
- Loading branch information
Jaymala
authored
Apr 21, 2023
1 parent
9bebe95
commit 166f270
Showing
2 changed files
with
53 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# This script validates if the git diff contains on docs changes | ||
|
||
event_type=$1 # GH event type (pull_request) | ||
ref_name=$2 # branch reference that triggered the workflow | ||
head_ref=$3 # PR branch head ref | ||
base_ref=$4 # PR branch base ref | ||
|
||
changed_dir="" | ||
|
||
if [[ "$event_type" == "pull_request" ]]; then | ||
git fetch --no-tags --prune origin $head_ref | ||
git fetch --no-tags --prune origin $base_ref | ||
head_commit="origin/$head_ref" | ||
prev_commit="origin/$base_ref" | ||
else | ||
git fetch --no-tags --prune origin $ref_name | ||
head_commit=$(git log origin/$ref_name --oneline | head -1 | awk '{print $1}') | ||
prev_commit=$(git log origin/$ref_name --oneline | head -2 | awk 'NR==2 {print $1}') | ||
fi | ||
|
||
change_count=$(git diff $head_commit..$prev_commit --name-only | awk -F"/" '{ print $1}' | uniq | wc -l) | ||
|
||
if [[ $change_count -eq 1 ]]; then | ||
changed_dir=$(git diff $head_commit..$prev_commit --name-only | awk -F"/" '{ print $1}' | uniq) | ||
fi | ||
|
||
if [[ "$changed_dir" == "website" ]]; then | ||
echo "is_docs_change=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "is_docs_change=false" >> "$GITHUB_OUTPUT" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters