Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action-readme pre-commit hook #23

Merged
merged 9 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .ci/scripts/action-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# This script updates the README.md files in the directories that contain both an action.yml and a README.md file.
# Prerequisites:
# - gh: GitHub CLI
#
set -euo pipefail

function find_dirs_with_action_yml_and_readme_md() {
find . \( -name 'action.yml' -o -name 'README.md' \) -exec dirname {} \; \
| sort \
| uniq -c \
| grep -E '^\s+2' \
| awk '{ print $2 }'
}

for dir in $(find_dirs_with_action_yml_and_readme_md); do
VERSION=v1 gh action-readme update --action="$dir/action.yml" --readme="$dir/README.md"
done
4 changes: 4 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install gh-action-readme
run: gh extension install reakaleek/gh-action-readme --pin v0.2.0
env:
GH_TOKEN: ${{ github.token }}
- uses: actions/setup-python@v5
- uses: pre-commit/[email protected]
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ repos:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: local
hooks:
- id: action-readme
name: action-readme
entry: .ci/scripts/action-readme.sh
language: script
pass_filenames: false
files: (action.ya?ml|README.md)$
Loading