Update documentation_workflow.yml #204
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Directory/Filename Formatter workflow | |
on: [push, pull_request] | |
jobs: | |
main: | |
name: (Directory) Formatter | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Git configuration | |
run: | | |
git config --global user.name 'autoprettier' | |
git config --global user.email 'actions@github.com' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY | |
- name: Filename Formatter | |
run: | | |
IFS=$'\n' | |
for fname in `find . -type f -name '*.R' -o -name '*.R'` | |
do | |
echo "${fname}" | |
new_fname=`echo ${fname} | tr ' ' '_'` | |
echo " ${new_fname}" | |
new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'` | |
echo " ${new_fname}" | |
new_fname=`echo ${new_fname} | tr '-' '_'` | |
echo " ${new_fname}" | |
if [ ${fname} != ${new_fname} ] | |
then | |
echo " ${fname} --> ${new_fname}" | |
git "mv" "${fname}" ${new_fname} | |
fi | |
done | |
git commit -am "Formatting filenames ${GITHUB_SHA::8}" || true | |
- name: Update DIRECTORY.md | |
run: | | |
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py | |
python3 build_directory_md.py R . .R,.r > DIRECTORY.md | |
git diff | |
git commit -m "Update DIRECTORY.md" DIRECTORY.md || true | |
git push --force origin HEAD:$GITHUB_REF || true |