feat: add README auto-updater workflow and cache input to setup-bazel
Update README Actions Table / update-readme (push) Failing after 28s
Update README Actions Table / update-readme (push) Failing after 28s
This commit is contained in:
@@ -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
|
||||||
@@ -1,2 +1,20 @@
|
|||||||
# shared-actions
|
# Shared Gitea Actions
|
||||||
|
|
||||||
|
This repository contains reusable composite actions for CI/CD workflows across our repositories.
|
||||||
|
|
||||||
|
## Available Actions
|
||||||
|
|
||||||
|
<!-- START_ACTIONS_TABLE -->
|
||||||
|
|
||||||
|
| 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` |
|
||||||
|
|
||||||
|
<!-- END_ACTIONS_TABLE -->
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
To use these actions in your workflows, reference them using the syntax:
|
||||||
|
`uses: rodydavis/shared-actions/<action-name>@main`
|
||||||
|
|||||||
Executable
+65
@@ -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"(<!-- START_ACTIONS_TABLE -->).*?(<!-- END_ACTIONS_TABLE -->)"
|
||||||
|
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()
|
||||||
@@ -9,6 +9,10 @@ inputs:
|
|||||||
description: 'Gitea token for private dependency authentication'
|
description: 'Gitea token for private dependency authentication'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
cache:
|
||||||
|
description: 'Used to specify a package manager for caching in actions/setup-node'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
@@ -17,6 +21,7 @@ runs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ inputs.node_version }}
|
node-version: ${{ inputs.node_version }}
|
||||||
|
cache: ${{ inputs.cache }}
|
||||||
|
|
||||||
- name: Set up Bazel (Bazelisk)
|
- name: Set up Bazel (Bazelisk)
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
Reference in New Issue
Block a user