diff --git a/.github/workflows/auto-format.yml b/.github/workflows/auto-format.yml index 69ea3dd0..47485c7e 100644 --- a/.github/workflows/auto-format.yml +++ b/.github/workflows/auto-format.yml @@ -26,18 +26,15 @@ jobs: run: | pip install -r requirements_test.txt - - name: Code formatting and committing changes + - name: Updating README files run: | - sh scripts/auto-format-commit.sh + sh scripts/update-readme.sh + sh scripts/auto-commit.sh "Updating README files" - - name: Print github.ref + - name: Code formatting and committing changes run: | - echo "github.ref:" - echo ${{ github.ref }} - echo "git branch:" - git branch - echo "github.head_ref" - echo ${{ github.head_ref }} + sh scripts/auto-format-commit.sh + sh scripts/auto-commit.sh "Automated formatting changes" - name: Push changes uses: ad-m/github-push-action@master diff --git a/scripts/auto-format-commit.sh b/scripts/auto-commit.sh similarity index 52% rename from scripts/auto-format-commit.sh rename to scripts/auto-commit.sh index a69789bc..3e2cfc34 100644 --- a/scripts/auto-format-commit.sh +++ b/scripts/auto-commit.sh @@ -1,15 +1,11 @@ #!/bin/sh -echo "Updating README files:" -# Update version number in README files: -scripts/update_version_readme.sh -# Update README.tex.md -scripts/update_readme.tex.md.sh +COMMITMSG=$1 -# Code formatting with isort and black -echo "Code formatting with isort and black:" -isort $(git ls-files '*.py') -black $(git ls-files '*.py') +if [ -z $COMMITMSG ]; then + COMMITMSG="Automated formatting changes" +fi +echo "COMMITMSG: $COMMITMSG" # Stage changes #git add $(git ls-files) @@ -24,8 +20,8 @@ else echo "Changes found. Preparing commit." git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - git commit -m "Automated formatting changes" + git commit -m "${COMMITMSG}" fi git log | head -exit 0 \ No newline at end of file +exit 0 diff --git a/scripts/auto-format.sh b/scripts/auto-format.sh new file mode 100644 index 00000000..442ad4e1 --- /dev/null +++ b/scripts/auto-format.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# Code formatting with isort and black +echo "Code formatting with isort and black:" +isort $(git ls-files '*.py') +black $(git ls-files '*.py') + +## Stage changes +##git add $(git ls-files) +#git add --udpate +# +## Check Git diff-index +#git diff-index --quiet HEAD -- +# +#if [ $? -eq 0 ]; then +# echo "No changes found, nothing to see/do here." +#else +# echo "Changes found. Preparing commit." +# git config --local user.email "github-actions[bot]@users.noreply.github.com" +# git config --local user.name "github-actions[bot]" +# git commit -m "Automated formatting changes" +#fi +# +#git log | head +#exit 0 diff --git a/scripts/update_readme.sh b/scripts/update-readme.sh similarity index 96% rename from scripts/update_readme.sh rename to scripts/update-readme.sh index 014a7dc7..6f92f16a 100644 --- a/scripts/update_readme.sh +++ b/scripts/update-readme.sh @@ -38,5 +38,6 @@ update_readme_tex() { } # Update both readme files: +echo "Updating README files:" update_version_readme "README.md" -update_readme_tex "README.tex.md" \ No newline at end of file +update_readme_tex "README.tex.md"