mirror of
https://github.com/ivuorinen/actions.git
synced 2026-02-18 03:48:55 +00:00
feat: add GitHub Actions workflows for code quality and automation (#2)
This commit is contained in:
64
run.sh
Executable file
64
run.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Check if the OS is macOS or Linux
|
||||
if [[ $OSTYPE == "darwin"* ]]; then
|
||||
# macOS needs -i .bak because it doesn't support -i without arguments
|
||||
SED_CMD="sed -i .bak"
|
||||
else
|
||||
# Linux supports -i without arguments
|
||||
SED_CMD="sed -i"
|
||||
fi
|
||||
|
||||
find . -mindepth 1 -maxdepth 1 -type d | while read -r dir; do
|
||||
dir=${dir#./}
|
||||
action="./$dir/action.yml"
|
||||
|
||||
# if action doesn't exist, skip
|
||||
if [ ! -f "$action" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
repo="ivuorinen/actions/$dir"
|
||||
readme="./$dir/README.md"
|
||||
version=$(grep -E '^# version:' "$action" | cut -d ' ' -f 2)
|
||||
|
||||
# if version doesn't exist, use 'main'
|
||||
if [ -z "$version" ]; then
|
||||
version="main"
|
||||
fi
|
||||
|
||||
echo "Updating $readme..."
|
||||
|
||||
printf "# %s\n\n" "$repo" >"$readme"
|
||||
|
||||
echo "- Generating action documentation..."
|
||||
npx --yes action-docs@latest \
|
||||
--source="$action" \
|
||||
--no-banner \
|
||||
--include-name-header >>"$readme"
|
||||
|
||||
echo "- Replacing placeholders in $readme..."
|
||||
$SED_CMD "s|PROJECT|$repo|g; s|VERSION|$version|g; s|\*\*\*||g" "$readme"
|
||||
|
||||
if [ -f "$readme.bak" ]; then
|
||||
rm "$readme.bak"
|
||||
echo "- Removed $readme.bak"
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
|
||||
echo "Running markdownlint..."
|
||||
npx --yes markdownlint-cli --fix \
|
||||
--ignore "**/node_modules/**" "**/README.md"
|
||||
echo ""
|
||||
|
||||
echo "Running prettier..."
|
||||
npx --yes prettier --write \
|
||||
"run.sh", "**/README.md" "**/action.yml" ".github/workflows/*.yml"
|
||||
echo ""
|
||||
|
||||
echo "Running MegaLinter..."
|
||||
npx --yes mega-linter-runner
|
||||
echo ""
|
||||
|
||||
echo "Done!"
|
||||
Reference in New Issue
Block a user