8000 Fix workflows (hopefully) (#10) · TheAlgorithms/scripts@d181ce6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d181ce6

Browse files
authored
Fix workflows (hopefully) (#10)
1 parent 838ea73 commit d181ce6

File tree

6 files changed

+40
-14
lines changed

6 files changed

+40
-14
lines changed

.github/workflows/directory-ignore-files.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v3
1212
- uses: ./directory_md
1313
with:
14-
language: C++
14+
language: scripts
1515
working-directory: .
1616
filetypes: .cpp,.hpp
1717
ignored-directories: ./test

.github/workflows/directory.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ jobs:
1111
- uses: actions/checkout@v3
1212
- uses: ./directory_md
1313
with:
14-
language: C++
14+
language: scripts
1515
working-directory: ./test
1616
filetypes: .cpp,.hpp

DIRECTORY.md

Whitespace-only changes.

directory_md/action.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@ runs:
2727
uses: actions/setup-python@v4
2828
with:
2929
python-version: '3.10' # or whatever version you support
30+
- name: Setup Git configurations
31+
shell: bash
32+
run: |
33+
git config --global user.name github-actions[bot]
34+
git config --global user.email 'github-actions@users.noreply.github.com'
3035
- name: Running the formatter
3136
shell: bash
3237
run: |
33-
python ../build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
38+
python ./build_directory_md.py ${{ inputs.language }} ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignored-directories }} ${{ inputs.ignore-folders-children }} > DIRECTORY.md
39+
- name: Committing changes
40+
shell: bash
41+
run: |
42+
git commit -m "chore: update `DIRECTORY.md`" DIRECTORY.md || true
43+
git push origin HEAD:$GITHUB_REF || true

filename_formatter.sh

+15-9
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,29 @@ echo -e "Arguments:
77
[3] - Ignored files or folders (optional; use "\""./<directory_name>"\"")
88
"
99

10-
echo "Changed files:"
11-
12-
1310
# Separate $2 value (filename types) if it has a comma
1411
if [[ "$2" == *","* ]];
1512
then
16-
string="$2"
13+
string="$2"
1714

18-
str_value=${string#*,}
19-
str_value2=${string%%,*}
15+
str_value=${string#*,}
16+
str_value2=${string%%,*}
2017
else
21-
str_value="$2"
22-
str_value2="$2"
18+
str_value="$2"
19+
str_value2="$2"
20+
fi
21+
22+
# Do not run script if there are no given arguments.
23+
if [[ "$1" == "" ]] || [[ "$2" == "" ]];
24+
then
25+
echo "No arguments given. Please specify minimum two arguments."
26+
exit 1
2327
fi
2428

29+
echo "Changed files:"
30+
2531
IFS=$'\n'; set -f
26-
for fname in `find $1 -type f -name "$str_value2" -o -name "$str_value"`
32+
for fname in $(find $1 -type f -name "*$str_value2" -or -name "*$str_value")
2733
do
2834
ignored_files="$(echo "$3" | tr "," "\n")"
2935

formatter/action.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Filename Formatter"
2-
description: "Format filenames into the format acceptable by TheAlgorithms opganization"
2+
description: "Format filenames into the acceptable format by TheAlgorithms opganization"
33
author: "TheAlgorithms"
44
inputs:
55
filetypes:
@@ -17,7 +17,17 @@ runs:
1717
steps:
1818
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
1919
shell: bash
20+
- name: Setup Git configurations
21+
shell: bash
22+
run: |
23+
git config --global user.name github-actions[bot]
24+
git config --global user.email 'github-actions@users.noreply.github.com'
2025
- name: Running the formatter
2126
shell: bash
2227
run: |
23-
../filename_formatter.sh ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignore-files }}
28+
./filename_formatter.sh ${{ inputs.working-directory }} ${{ inputs.filetypes }} ${{ inputs.ignore-files }}
29+
- name: Committing changes
30+
shell: bash
31+
run: |
32+
git commit -m "chore: formatting filenames`" DIRECTORY.md || true
33+
git push origin HEAD:$GITHUB_REF || true

0 commit comments

Comments
 (0)
0