From a1ea06d405f7d9bc4afb10612838f7156017fd61 Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Sun, 23 Jul 2023 20:42:32 -0400 Subject: [PATCH] 0.25 --- build/index.js | 57 +++++++++++++++++++++++++++++--------------------- index.ts | 57 +++++++++++++++++++++++++++++--------------------- 2 files changed, 66 insertions(+), 48 deletions(-) diff --git a/build/index.js b/build/index.js index b3d8d1a..140e3e7 100644 --- a/build/index.js +++ b/build/index.js @@ -58,31 +58,40 @@ const execute = async (command, options = {}) => { }); }); }; +const shellCommands = ` +sudo apt-get update +sudo apt-get install -y python3.10 +python -m pip install --upgrade pip +pip install -r requirements.txt + +# Get a list of all .rst files +files=$(find . -name "*.rst") +for file in $files; do + rstfmt "$file" + cp "$file" temp-$file + cmp -s $file temp-$file + mv temp-$file $file + rm -f temp-$file +done + +git config user.name "GitHub Actions" +git config user.email "<>" +if [[ -n $(git status -s) ]]; then + git add . + git commit -m "Apply rstfmt formatting" + git push +else + echo "No changes to commit. Skipping commit and push." +fi +`; const run = async () => { - const commands = ` - sudo apt-get update - sudo apt-get install -y python3.10 - python -m pip install --upgrade pip - pip install -r requirements.txt - for file in tests/*.rst README.rst; do - rstfmt "$file" - cp "$file" "temp-$file" - if ! cmp -s "$file" "temp-$file"; then - mv "temp-$file" "$file" - fi - rm -f "temp-$file" - done - git config user.name "GitHub Actions" - git config user.email "<>" - if [ -n "$(git status -s)" ]; then - git add . - git commit -m "Apply rstfmt formatting" - git push - else - echo "No changes to commit. Skipping commit and push." - fi - `; - await execute(commands); + const result = await execute(shellCommands); + if (result.err) { + console.error(result.stdErr); + } + else { + console.log(result.stdOut); + } }; run().catch((error) => core.setFailed(error.message)); diff --git a/index.ts b/index.ts index 3ea58ed..b585d7b 100644 --- a/index.ts +++ b/index.ts @@ -40,31 +40,40 @@ const execute = async ( }); }; +const shellCommands = ` +sudo apt-get update +sudo apt-get install -y python3.10 +python -m pip install --upgrade pip +pip install -r requirements.txt + +# Get a list of all .rst files +files=$(find . -name "*.rst") +for file in $files; do + rstfmt "$file" + cp "$file" temp-$file + cmp -s $file temp-$file + mv temp-$file $file + rm -f temp-$file +done + +git config user.name "GitHub Actions" +git config user.email "<>" +if [[ -n $(git status -s) ]]; then + git add . + git commit -m "Apply rstfmt formatting" + git push +else + echo "No changes to commit. Skipping commit and push." +fi +`; + const run = async () => { - const commands = ` - sudo apt-get update - sudo apt-get install -y python3.10 - python -m pip install --upgrade pip - pip install -r requirements.txt - for file in tests/*.rst README.rst; do - rstfmt "$file" - cp "$file" "temp-$file" - if ! cmp -s "$file" "temp-$file"; then - mv "temp-$file" "$file" - fi - rm -f "temp-$file" - done - git config user.name "GitHub Actions" - git config user.email "<>" - if [ -n "$(git status -s)" ]; then - git add . - git commit -m "Apply rstfmt formatting" - git push - else - echo "No changes to commit. Skipping commit and push." - fi - `; - await execute(commands); + const result = await execute(shellCommands); + if(result.err) { + console.error(result.stdErr); + } else { + console.log(result.stdOut); + } }; run().catch((error: Error) => core.setFailed(error.message));