Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/actions/utils/fs/clean-dir/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Clean directory
description: clean directory with excludes

inputs:
targetDirectory:
description: working directory
default: tmp/target
required: true
syncIgnore:
description: working directory
default: tmp/target
required: true

runs:
using: composite

steps:
- name: Clean target directory except excluded files
shell: bash
working-directory: ${{ inputs.targetDirectory }}
env:
SYNC_IGNORE: ${{ inputs.syncIgnore }}
run: |
IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE"

exclude_conditions=""
for ignored_file in "${ignored_files[@]}"; do
exclude_conditions=" $exclude_conditions ! -path \"./$ignored_file/*\" ! -path \"./$ignored_file\""
done

echo "$exclude_conditions"

eval find . -mindepth 1 $exclude_conditions -type f -exec rm -f {} +
find . -mindepth 1 -type d -empty -delete
32 changes: 32 additions & 0 deletions .github/actions/utils/fs/rename-dirs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Rename directories
description: rename directories

inputs:
targetDirectory:
description: working directory
default: tmp/target
required: true
sourceDirname:
description: dirname to rename
required: true
targetDirname:
description: name to rename
required: true

runs:
using: composite

steps:
- name: Rename directories
shell: bash
working-directory: ${{ inputs.targetDirectory }}
run: |
find . -depth -type d -iname '*${{ inputs.sourceDirname }}*' -exec bash -c '
for dir; do
newdir=$(echo "$dir" | sed -e "s/${{ inputs.sourceDirname }}/${{ inputs.targetDirname }}/gi")
if [ "$dir" != "$newdir" ]; then
echo "Renaming directory: $dir -> $newdir"
mv "$dir" "$newdir"
fi
done
' bash {} +
50 changes: 50 additions & 0 deletions .github/actions/utils/fs/replace-file-content/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Replace file content
description: replace file content

inputs:
targetDirectory:
description: working directory
default: tmp/target
required: true
syncIgnore:
description: working directory
default: tmp/target
required: true
replacementExtentions:
required: true
description: list of extentions to replace, separated by ','
default: "*.ts,*.sh,*.yaml"
replacementContents:
required: true
description: list of contents to replace, separated by ',' and '|' - separate source target content\
default: "source:content:1|target:conten:1,source-content-1|target-content-1"

runs:
using: composite

steps:
- name: Replace file content
shell: bash
working-directory: ${{ inputs.targetDirectory }}
env:
REPLACMENT_EXTENTIONS: ${{ inputs.replacementExtentions }}
REPLACEMENT_CONTENTS: ${{ inputs.replacementContents }}
run: |
IFS=',' read -r -a replacement_extentions <<< "$REPLACMENT_EXTENTIONS"
IFS=',' read -r -a replacement_contents <<< "$REPLACEMENT_CONTENTS"

find_conditions=""
for extention in "${replacement_extentions[@]}"; do
if [ -z "$find_conditions" ]; then
find_conditions="-name \"$extention\""
else
find_conditions="$find_conditions -o -name \"$extention\""
fi
done

sed_arguments=""
for replacement_content in "${replacement_contents[@]}"; do
sed_arguments+="-e 's|$replacement_content|g' "
done

eval "find . -type f \( $find_conditions \) -exec sed -i $sed_arguments" {} +
43 changes: 43 additions & 0 deletions .github/actions/utils/fs/sync-dirs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Sync directories
description: synchronization directories with excludes

inputs:
sourceDirectory:
description: working directory
default: tmp/source
required: true
targetDirectory:
description: working directory
default: tmp/target
required: true
syncIgnore:
description: working directory

runs:
using: composite

steps:
- name: Sync files to remote repository
if: ${{ inputs.syncIgnore != '' }}
shell: bash
env:
SYNC_IGNORE: ${{ inputs.syncIgnore }}
SOURCE_TMP_DIR_PATH: ${{ inputs.sourceDirectory }}
TARGET_TMP_DIR_PATH: ${{ inputs.targetDirectory }}
run: |
IFS=',' read -r -a ignored_files <<< "$SYNC_IGNORE"

exclude_conditions=""
for ignored_file in "${ignored_files[@]}"; do
exclude_conditions=" $exclude_conditions --exclude \"$ignored_file\""
done

echo $exclude_conditions

eval rsync -av --progress "$SOURCE_TMP_DIR_PATH" "$TARGET_TMP_DIR_PATH" $exclude_conditions

- name: Sync files to remote repository
if: ${{ inputs.syncIgnore == '' }}
shell: bash
run: |
rsync -av --progress "${{ inputs.targetDirectory }}" "${{ inputs.sourceDirectory }}"
Loading