diff --git a/.gitea/workflows/update-readme.yml b/.gitea/workflows/update-readme.yml new file mode 100644 index 0000000..b6685a2 --- /dev/null +++ b/.gitea/workflows/update-readme.yml @@ -0,0 +1,40 @@ +name: Update README Actions Table + +on: + push: + branches: ["main", "master"] + paths: + - '**/action.yml' + - '**/action.yaml' + - 'scripts/update-readme.py' + +jobs: + update-readme: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Update README table + run: | + chmod +x scripts/update-readme.py + ./scripts/update-readme.py + + - name: Commit and Push changes + run: | + git config --global user.name "Gitea Actions" + git config --global user.email "actions@gitea.local" + git add README.md + if ! git diff-index --quiet HEAD; then + git commit -m "docs: auto-update README actions table [skip ci]" + git push origin HEAD:${{ github.ref_name }} + else + echo "No changes to commit" + fi diff --git a/README.md b/README.md index 36e2bc8..0b9ecca 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# shared-actions +# Shared Gitea Actions +This repository contains reusable composite actions for CI/CD workflows across our repositories. + +## Available Actions + + + +| Action | Description | Reference | +| :--- | :--- | :--- | +| [Enforce Flutter Version Constraint](./enforce-flutter-version) | Scans all pubspec.yaml files to ensure they use the required Flutter SDK constraint. | `rodydavis/shared-actions/enforce-flutter-version@main` | +| [Run Buildifier](./run-buildifier) | Downloads and runs buildifier on Starlark files. | `rodydavis/shared-actions/run-buildifier@main` | +| [Setup Bazel (Bazelisk)](./setup-bazel) | Installs Node, Bazelisk, and configures Git for private SSH dependencies. | `rodydavis/shared-actions/setup-bazel@main` | + + + +## Usage + +To use these actions in your workflows, reference them using the syntax: +`uses: rodydavis/shared-actions/@main` diff --git a/scripts/update-readme.py b/scripts/update-readme.py new file mode 100755 index 0000000..72c9bd1 --- /dev/null +++ b/scripts/update-readme.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +import os +import re + +def parse_action_yml(file_path): + name = "" + description = "" + with open(file_path, "r", encoding="utf-8") as f: + for line in f: + # Only match top-level keys (no indentation) + if line and not line.startswith(" ") and not line.startswith("\t"): + line_stripped = line.strip() + if line_stripped.startswith("name:"): + name = line_stripped.split("name:", 1)[1].strip().strip("'\"") + elif line_stripped.startswith("description:"): + description = line_stripped.split("description:", 1)[1].strip().strip("'\"") + return name, description + +def main(): + repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + readme_path = os.path.join(repo_root, "README.md") + + actions = [] + for entry in sorted(os.listdir(repo_root)): + entry_path = os.path.join(repo_root, entry) + if os.path.isdir(entry_path) and not entry.startswith('.'): + for filename in ["action.yml", "action.yaml"]: + action_yml = os.path.join(entry_path, filename) + if os.path.exists(action_yml): + name, desc = parse_action_yml(action_yml) + actions.append({ + "dir": entry, + "name": name or entry, + "description": desc or "No description provided." + }) + break + + # Build Markdown Table + table_lines = [ + "| Action | Description | Reference |", + "| :--- | :--- | :--- |" + ] + for action in actions: + ref = f"`rodydavis/shared-actions/{action['dir']}@main`" + link = f"[{action['name']}](./{action['dir']})" + table_lines.append(f"| {link} | {action['description']} | {ref} |") + + table_content = "\n".join(table_lines) + + # Update README + with open(readme_path, "r", encoding="utf-8") as f: + readme_content = f.read() + + pattern = r"().*?()" + replacement = f"\\1\n\n{table_content}\n\n\\2" + + new_readme_content = re.sub(pattern, replacement, readme_content, flags=re.DOTALL) + + with open(readme_path, "w", encoding="utf-8") as f: + f.write(new_readme_content) + + print("README.md updated successfully!") + +if __name__ == "__main__": + main() diff --git a/setup-bazel/action.yml b/setup-bazel/action.yml index 5f80e80..16cf2af 100644 --- a/setup-bazel/action.yml +++ b/setup-bazel/action.yml @@ -9,6 +9,10 @@ inputs: description: 'Gitea token for private dependency authentication' required: false default: '' + cache: + description: 'Used to specify a package manager for caching in actions/setup-node' + required: false + default: '' runs: using: 'composite' @@ -17,6 +21,7 @@ runs: uses: actions/setup-node@v4 with: node-version: ${{ inputs.node_version }} + cache: ${{ inputs.cache }} - name: Set up Bazel (Bazelisk) shell: bash