Skip to content

Commit

Permalink
created new script to remove carraige returns
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveW-STFC committed Oct 3, 2024
1 parent 3787dfb commit 49aec42
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/pr_check_copy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# Script to check if the changed files to promote are a direct copy of earlier environment

# Function to compare the files, file1 is our original file passed to the script followed by two possible further files
compare_files() {
file1=$1
file2=$2
file3=$3

# Check the number of arguments passed to the function for comparison
# To know the number of files for comparison
# We then check whether the files exist in the previous environment, if not the PR needs review
if [ "$#" -eq 2 ]; then
if [ -f $file2 ]; then
if cmp -s "$file1" "$file2"; then
echo $((0))
else
echo $((1))
fi
else
echo $((1))
fi
else
if [[ -f $file2 && -f $file3 ]]; then
if cmp -s "$file1" "$file2" && cmp -s "$file1" "$file3"; then
echo $((0))
else
echo $((1))
fi
else
echo $((1))
fi
fi
}

# Check the file path to determine if it's from staging or prod folder
# If it's staging we pass it along with a url to the file in dev folder
# If it's from prod we pass both the staging and dev file also for comparison
path=$1
curr_env=$2
comp_env=$3
comp_env2=$4

if [[ -z $4 ]]; then
compare_files "$1" "${path/$curr_env/"$comp_env"}"
else
compare_files "$1" "${path/$curr_env/"$comp_env"}" "${path/$curr_env/"$comp_env2"}"
fi
4 changes: 2 additions & 2 deletions .github/workflows/pr_copied_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
echo "Files that have changed: $STAGING_ALL_CHANGED_FILES"
echo "result=true" >> "$GITHUB_OUTPUT"
for file in ${{ steps.changed-files.outputs.staging_all_changed_files }}; do
res=$( sudo ./pr_check_copies.sh "$file" "staging" "dev" )
res=$( sudo ./pr_check_copy.sh "$file" "staging" "dev" )
echo $res
if [ "$res" -eq 1 ]; then
echo "result=false" >> "$GITHUB_OUTPUT"
Expand All @@ -63,7 +63,7 @@ jobs:
echo "Files that have changed: $PROD_ALL_CHANGED_FILES"
echo "result=true" >> "$GITHUB_OUTPUT"
for file in ${{ steps.changed-files.outputs.prod_all_changed_files }}; do
res=$( sudo ./pr_check_copies.sh "$file" "prod" "staging" )
res=$( sudo ./pr_check_copy.sh "$file" "prod" "staging" )
echo $res
if [ "$res" -eq 1 ]; then
echo "result=false" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 1 addition & 1 deletion charts/staging/argocd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
apiVersion: v2
name: argocd
version: 1.0.3
version: 1.0.4

0 comments on commit 49aec42

Please sign in to comment.