Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/directory-ignore-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./directory_md
with:
language: C++
language: scripts
working-directory: .
filetypes: .cpp,.hpp
ignored-directories: ./test
2 changes: 1 addition & 1 deletion .github/workflows/directory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
- uses: actions/checkout@v3
- uses: ./directory_md
with:
language: C++
language: scripts
working-directory: ./test
filetypes: .cpp,.hpp
Empty file added DIRECTORY.md
Empty file.
12 changes: 11 additions & 1 deletion directory_md/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@ runs:
uses: actions/setup-python@v4
with:
python-version: '3.10' # or whatever version you support
- name: Setup Git configurations
shell: bash
run: |
git config --global user.name github-actions[bot]
git config --global user.email 'github-actions@users.noreply.github.com'
- name: Running the formatter
shell: bash
run: |
python ../build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
python ./build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
- name: Committing changes
shell: bash
run: |
git commit -m "chore: update `DIRECTORY.md`" DIRECTORY.md || true
git push origin HEAD:$GITHUB_REF || true
24 changes: 15 additions & 9 deletions filename_formatter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ echo -e "Arguments:
[3] - Ignored files or folders (optional; use "\""./<directory_name>"\"")
"

echo "Changed files:"


# Separate $2 value (filename types) if it has a comma
if [[ "$2" == *","* ]];
then
string="$2"
string="$2"

str_value=${string#*,}
str_value2=${string%%,*}
str_value=${string#*,}
str_value2=${string%%,*}
else
str_value="$2"
str_value2="$2"
str_value="$2"
str_value2="$2"
fi

# Do not run script if there are no given arguments.
if [[ "$1" == "" ]] || [[ "$2" == "" ]];
then
echo "No arguments given. Please specify minimum two arguments."
exit 1
fi

echo "Changed files:"

IFS=$'\n'; set -f
for fname in `find $1 -type f -name "$str_value2" -o -name "$str_value"`
for fname in $(find $1 -type f -name "*$str_value2" -or -name "*$str_value")
do
ignored_files="$(echo "$3" | tr "," "\n")"

Expand Down
14 changes: 12 additions & 2 deletions formatter/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Filename Formatter"
description: "Format filenames into the format acceptable by TheAlgorithms opganization"
description: "Format filenames into the acceptable format by TheAlgorithms opganization"
author: "TheAlgorithms"
inputs:
filetypes:
Expand All @@ -17,7 +17,17 @@ runs:
steps:
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Setup Git configurations
shell: bash
run: |
git config --global user.name github-actions[bot]
git config --global user.email 'github-actions@users.noreply.github.com'
- name: Running the formatter
shell: bash
run: |
../filename_formatter.sh ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignore-files }}
./filename_formatter.sh ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignore-files }}
- name: Committing changes
shell: bash
run: |
git commit -m "chore: formatting filenames`" DIRECTORY.md || true
git push origin HEAD:$GITHUB_REF || true