Skip to content

Test documentation pipeline #2

Test documentation pipeline

Test documentation pipeline #2

Workflow file for this run

name: Documentation
true:
pull_request:
branches:
- main
paths:
- crates/q_cli/**
- docs/**
- .github/workflows/documentation.yml
push:
branches:
- main
paths:
- crates/q_cli/**
- docs/**
- .github/workflows/documentation.yml
jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: 'python -m pip install --upgrade pip
pip install markdown pyyaml
'
- name: Generate documentation
run: 'mkdir -p docs/generated
python scripts/extract_docs.py
'
- name: Install documentation enhancement dependencies
run: python -m pip install openai
- env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
name: Enhance documentation with LLM
run: python scripts/enhance_docs.py --input-dir docs/generated --code-dir .
--output-dir docs/enhanced
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Install mdBook
run: 'cargo install mdbook
'
- name: Setup mdBook structure
run: "mkdir -p docs/src\n cp -r docs/enhanced/* docs/src/\n\n# Create book.toml\n\
cat > docs/book.toml << EOF\n[book]\ntitle = \"Amazon Q Developer CLI Documentation\"\
\nauthors = [\"AWS\"]\ndescription = \"Documentation for the Amazon Q Developer\
\ CLI\"\nsrc = \"src\"\n\n[output.html]\ngit-repository-url = \"https://github.com/aws/amazon-q-developer-cli\"\
\ngit-repository-icon = \"fa-github\"\nsite-url = \"/\"\nEOF\n\n# Create SUMMARY.md\n\
echo \"# Summary\" > docs/src/SUMMARY.md\necho \"\" >> docs/src/SUMMARY.md\n\
echo \"[Introduction](README.md)\" >> docs/src/SUMMARY.md\necho \"\" >> docs/src/SUMMARY.md\n\
echo \"# Commands\" >> docs/src/SUMMARY.md\n\n# Add all command files to SUMMARY.md\n\
find docs/src -name \"*.md\" -not -path \"*/\\.*\" -not -name \"SUMMARY.md\"\
\ -not -name \"README.md\" | sort | while read -r file; do\n filename=$(basename\
\ \"$file\")\n title=$(head -n 1 \"$file\" | sed 's/^# //')\n if [ \"$filename\"\
\ != \"index.md\" ]; then\n echo \"- [$title]($filename)\" >> docs/src/SUMMARY.md\n\
\ fi\ndone\n\n# Create README.md if it doesn't exist\nif [ ! -f \"docs/src/README.md\"\
\ ]; then\n if [ -f \"docs/src/index.md\" ]; then\n cp docs/src/index.md\
\ docs/src/README.md\n else\n cat > docs/src/README.md << EOF\n# Amazon\
\ Q Developer CLI Documentation\n\nWelcome to the Amazon Q Developer CLI documentation.\
\ This site contains reference documentation for all Amazon Q CLI commands.\n\
\n## Available Commands\n\nSee the sidebar for a complete list of available\
\ commands.\nEOF\n fi\nfi\n"
- name: Build mdBook
run: 'cd docs && mdbook build
'
- name: Upload documentation artifact
uses: actions/upload-artifact@v3
with:
name: documentation
path: docs/book
deploy-infrastructure:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build-docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download documentation artifact
uses: actions/download-artifact@v3
with:
name: documentation
path: docs/book
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install CDK dependencies
run: 'cd infrastructure
npm install
'
- env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_DEFAULT_REGION: us-west-2
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Deploy CDK stack
run: 'cd infrastructure
npm run cdk deploy -- --require-approval never
'
deploy-preview:
if: github.event_name == 'pull_request'
needs: build-docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download documentation artifact
uses: actions/download-artifact@v3
with:
name: documentation
path: docs/book
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-region: us-west-2
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Deploy to S3 preview bucket
run: 'aws s3 sync docs/book s3://q-cli-docs-preview-${{ github.event.pull_request.number
}} --delete
'
- name: Comment on PR with preview link
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: "const previewUrl = `http://q-cli-docs-preview-${{ github.event.pull_request.number\
\ }}.s3-website-us-west-2.amazonaws.com`;\ngithub.rest.issues.createComment({\n\
\ issue_number: context.issue.number,\n owner: context.repo.owner,\n \
\ repo: context.repo.repo,\n body: `\U0001F4DA Documentation preview available\
\ at: [${previewUrl}](${previewUrl})`\n});\n"