Skip to content

Commit

Permalink
store script and run that
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Jan 9, 2024
1 parent c0782b3 commit d929bed
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 45 deletions.
37 changes: 37 additions & 0 deletions .github/scripts/copy_toml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# This script searches for TOML files matching given regex patterns and copies them to a target directory.

echo "patterns: $1"
echo "search_folder: $2"
echo "target_folder: $3"

if [ "$#" -ne 3 ]; then
echo "Usage: $0 <pattern-array> <search-folder> <target-folder>"
exit 1
fi

declare -a patterns=($1) # Array of regex filename patterns
search_folder=$2 # Folder to search in
target_folder=$3 # Target folder for copying files

if [ ! -d "$search_folder" ]; then
echo "Search folder does not exist: $search_folder"
exit 1
fiwhy

mkdir -p "$target_folder"

copy_files() {
local pattern=$1
# Find .toml files, extract filenames, and match pattern
find "$search_folder" -type f -name "*.toml" | while read -r file; do
filename=$(basename "$file")
if [[ $filename =~ $pattern ]]; then
cp "$file" "$target_folder"
fi
done
}

for pattern in "${patterns[@]}"; do
copy_files "$pattern"
done
47 changes: 2 additions & 45 deletions .github/workflows/client-compatibility-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,51 +79,8 @@ jobs:
# and we need these default values if we don't want to create them in flight
- name: Gather TOML config files
run: |
set -x
cat << EOF > copy_toml.sh
#!/bin/bash
# This script searches for TOML files matching given regex patterns and copies them to a target directory.
echo "patterns: $1"
echo "search_folder: $2"
echo "target_folder: $3"
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <pattern-array> <search-folder> <target-folder>"
exit 1
fi
declare -a patterns=($1) # Array of regex filename patterns
search_folder=$2 # Folder to search in
target_folder=$3 # Target folder for copying files
if [ ! -d "$search_folder" ]; then
echo "Search folder does not exist: $search_folder"
exit 1
fiwhy
mkdir -p "$target_folder"
copy_files() {
local pattern=$1
# Find .toml files, extract filenames, and match pattern
find "$search_folder" -type f -name "*.toml" | while read -r file; do
filename=$(basename "$file")
if [[ $filename =~ $pattern ]]; then
cp "$file" "$target_folder"
fi
done
}
for pattern in "${patterns[@]}"; do
copy_files "$pattern"
done
echo "Copy operation completed."
EOF
chmox +x ./copy_toml.sh
./copy_toml.sh "default ocr" ./integration-tests ./toml_configs
set -x
./.github/scripts/copy_toml.sh "default ocr" ./integration-tests ./toml_configs
cd ./toml_configs && zip toml_configs.zip ./
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
Expand Down
37 changes: 37 additions & 0 deletions copy_toml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# This script searches for TOML files matching given regex patterns and copies them to a target directory.

echo "patterns: $1"
echo "search_folder: $2"
echo "target_folder: $3"

if [ "$#" -ne 3 ]; then
echo "Usage: $0 <pattern-array> <search-folder> <target-folder>"
exit 1
fi

declare -a patterns=($1) # Array of regex filename patterns
search_folder=$2 # Folder to search in
target_folder=$3 # Target folder for copying files

if [ ! -d "$search_folder" ]; then
echo "Search folder does not exist: $search_folder"
exit 1
fiwhy

mkdir -p "$target_folder"

copy_files() {
local pattern=$1
# Find .toml files, extract filenames, and match pattern
find "$search_folder" -type f -name "*.toml" | while read -r file; do
filename=$(basename "$file")
if [[ $filename =~ $pattern ]]; then
cp "$file" "$target_folder"
fi
done
}

for pattern in "${patterns[@]}"; do
copy_files "$pattern"
done

0 comments on commit d929bed

Please sign in to comment.