Skip to content

Commit

Permalink
0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Jul 24, 2023
1 parent 8a70f5f commit a1ea06d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 48 deletions.
57 changes: 33 additions & 24 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
57 changes: 33 additions & 24 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

0 comments on commit a1ea06d

Please sign in to comment.