documentation
Directory actions
More options
Directory actions
More options
documentation
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
# 📄 README Generator Workflow - Example
# This is an example showing how to use the documentation.yml workflow components
name: 📄 README Generator Example
on:
push:
branches: [main, develop]
paths:
- 'docs/README.template.MD'
- '.github/actions/readme-generate/**'
tags:
- 'v*'
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches: [main]
paths:
- 'docs/README.template.MD'
workflow_dispatch:
inputs:
force-update:
description: 'Force README update even without changes'
type: boolean
default: false
custom-version:
description: 'Custom version for README'
type: string
default: ''
template-path:
description: 'Path to README template'
type: string
default: 'docs/README.template.MD'
output-path:
description: 'Output path for generated README'
type: string
default: 'README.MD'
permissions:
contents: write
pull-requests: write
jobs:
# Basic README generation example
generate-readme:
name: Generate README
runs-on: ubuntu-latest
outputs:
readme_updated: ${{ steps.generate.outputs.readme_updated }}
changes_detected: ${{ steps.generate.outputs.changes_detected }}
steps:
- name: 🚀 Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: 🔍 Validate Template File
run: |
TEMPLATE_FILE="${{ inputs.template-path || 'docs/README.template.MD' }}"
if [ ! -f "$TEMPLATE_FILE" ]; then
echo "❌ Template file not found: $TEMPLATE_FILE"
echo "💡 Available template files:"
find . -name "*.template.*" -type f | head -10
exit 1
fi
echo "✅ Template file found: $TEMPLATE_FILE"
echo "📊 Template size: $(wc -c < "$TEMPLATE_FILE") bytes"
- name: 📝 Generate README with Custom Action
id: generate
uses: bauer-group/automation-templates/.github/actions/readme-generate@main
with:
template-path: ${{ inputs.template-path || 'docs/README.template.MD' }}
output-path: ${{ inputs.output-path || 'README.MD' }}
project-name: 'Example Project'
company-name: 'Your Company'
project-description: 'An example project demonstrating README generation'
contact-email: 'contact@yourcompany.com'
documentation-url: 'https://github.com/your-org/your-repo/wiki'
support-url: 'https://github.com/your-org/your-repo/issues'
force-update: ${{ inputs.force-update || startsWith(github.ref, 'refs/tags/') }}
custom-version: ${{ inputs.custom-version || (startsWith(github.ref, 'refs/tags/') && github.ref_name) || '' }}
- name: 📄 Auto-commit Changes
if: steps.generate.outputs.changes_detected == 'true' && github.event_name != 'pull_request'
run: |
git config --local user.email "action@github.com"
git config --local user.name "📄 README Bot"
# Build dynamic commit message
COMMIT_MSG="docs: update ${{ inputs.output-path || 'README.MD' }}"
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
COMMIT_MSG="$COMMIT_MSG for release ${{ github.ref_name }}"
elif [ "${{ github.event_name }}" = "schedule" ]; then
COMMIT_MSG="$COMMIT_MSG (scheduled)"
elif [ "${{ inputs.force-update }}" = "true" ]; then
COMMIT_MSG="$COMMIT_MSG (forced)"
elif [ -n "${{ inputs.custom-version }}" ]; then
COMMIT_MSG="$COMMIT_MSG (v${{ inputs.custom-version }})"
fi
COMMIT_MSG="$COMMIT_MSG [automated]"
git add "${{ inputs.output-path || 'README.MD' }}"
git commit -m "$COMMIT_MSG" || echo "No changes to commit"
git push
# Optional: Extended validation example
validate-readme:
name: Validate Generated README
needs: generate-readme
runs-on: ubuntu-latest
if: always()
steps:
- name: 🚀 Checkout Repository
uses: actions/checkout@v4
- name: 🔍 Validate README Structure
run: |
README_FILE="${{ inputs.output-path || 'README.MD' }}"
echo "🔍 Validating $README_FILE structure..."
if [ ! -f "$README_FILE" ]; then
echo "❌ Generated README not found: $README_FILE"
exit 1
fi
# Check for common sections
REQUIRED_SECTIONS=("# " "## " "### ")
MISSING_SECTIONS=()
for section in "${REQUIRED_SECTIONS[@]}"; do
if ! grep -q "^$section" "$README_FILE"; then
MISSING_SECTIONS+=("$section")
fi
done
if [ ${#MISSING_SECTIONS[@]} -gt 0 ]; then
echo "⚠️ Missing sections in README:"
for section in "${MISSING_SECTIONS[@]}"; do
echo " - $section"
done
else
echo "✅ All required sections found"
fi
# Check file size
FILE_SIZE=$(wc -c < "$README_FILE")
echo "📊 Generated README size: $FILE_SIZE bytes"
if [ $FILE_SIZE -lt 100 ]; then
echo "⚠️ README seems too small ($FILE_SIZE bytes)"
elif [ $FILE_SIZE -gt 50000 ]; then
echo "⚠️ README seems very large ($FILE_SIZE bytes)"
else
echo "✅ README size looks good"
fi
- name: 📊 Summary Report
if: always()
run: |
echo "### 📄 README Generation Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| **Generation** | ${{ needs.generate-readme.outputs.readme_updated && '✅ Updated' || '⏭️ No changes' }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Validation** | ${{ job.status == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| **Auto-commit** | ${{ github.event_name != 'pull_request' && needs.generate-readme.outputs.changes_detected == 'true' && '✅ Committed' || '⏭️ Skipped' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.generate-readme.outputs.readme_updated }}" = "true" ]; then
echo "🎉 **README successfully generated and updated!**" >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ **No updates needed - README is up to date**" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Configuration used:**" >> $GITHUB_STEP_SUMMARY
echo "- Template: \`${{ inputs.template-path || 'docs/README.template.MD' }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Output: \`${{ inputs.output-path || 'README.MD' }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Force Update: \`${{ inputs.force-update || false }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Custom Version: \`${{ inputs.custom-version || 'auto' }}\`" >> $GITHUB_STEP_SUMMARY