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 all 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)$
24 changes: 24 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Contribution Guidelines

## Prerequisites

### Pre-commit

This repository uses [pre-commit](https://pre-commit.com/) to enforce code quality.
To install pre-commit follow the instructions [here](https://pre-commit.com/#install).

After installing pre-commit, run the following command to install the pre-commit hooks:

```bash
pre-commit install
```

### GitHub CLI

This repository uses the [gh-action-readme](https://github.com/reakaleek/gh-action-readme) GitHub CLI extension to generate and update the `README.md` files for the actions.
To install the GitHub CLI follow the instructions [here](https://github.com/cli/cli#installation).

After installing the GitHub CLI, run the following command to install the `gh-action-readme` extension:

```bash
gh extension install reakaleek/gh-action-readme
```

## Action Documentation
Every action should have a `README.md` file in its directory.
The `README.md` file is generated and updated by the [gh-action-readme](https://github.com/reakaleek/gh-action-readme)
Expand Down
Loading