publish-assets #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build and deploy index.json, llms.txt, and/or llms-full.txt from all product documentation | |
| name: publish-assets | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target: | |
| description: 'Asset to publish' | |
| type: choice | |
| options: | |
| - all | |
| - index.json | |
| - llms.txt | |
| - llms-full.txt | |
| default: 'all' | |
| environment: | |
| description: 'Target environment' | |
| type: choice | |
| options: | |
| - prod | |
| - qa | |
| default: 'qa' | |
| jobs: | |
| build: | |
| runs-on: self-hosted | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Hugo | |
| run: | | |
| curl -LO https://github.com/gohugoio/hugo/releases/download/v0.101.0/hugo_extended_0.101.0_Linux-64bit.deb | |
| sudo dpkg -i hugo_extended_0.101.0_Linux-64bit.deb | |
| - name: Download documentation repositories | |
| run: | | |
| # Each entry is "product_key:ProductName" | |
| # Repo URL pattern: https://github.com/groupdocs-{key}/GroupDocs.{Name}-Docs | |
| PRODUCTS=" | |
| annotation:Annotation | |
| assembly:Assembly | |
| classification:Classification | |
| comparison:Comparison | |
| conversion:Conversion | |
| editor:Editor | |
| markdown:Markdown | |
| merger:Merger | |
| metadata:Metadata | |
| parser:Parser | |
| redaction:Redaction | |
| search:Search | |
| signature:Signature | |
| total:Total | |
| viewer:Viewer | |
| watermark:Watermark | |
| " | |
| for entry in $PRODUCTS; do | |
| product="${entry%%:*}" | |
| product_name="${entry##*:}" | |
| repo_url="https://github.com/groupdocs-${product}/GroupDocs.${product_name}-Docs.git" | |
| echo "::group::Downloading ${product} documentation" | |
| echo "Repository: groupdocs-${product}/GroupDocs.${product_name}-Docs" | |
| git clone --depth 1 "${repo_url}" "temp-${product}" 2>&1 || { | |
| echo "::warning::Failed to clone GroupDocs.${product_name}-Docs" | |
| echo "::endgroup::" | |
| continue | |
| } | |
| # Create content directory for this product | |
| mkdir -p "content/${product}" | |
| # Copy product family index page | |
| if [ -f "temp-${product}/_index.md" ]; then | |
| cp "temp-${product}/_index.md" "content/${product}/" | |
| echo "Copied _index.md" | |
| fi | |
| # Copy platform-specific documentation folders | |
| for platform in net java nodejs-java python-net; do | |
| if [ -d "temp-${product}/${platform}" ]; then | |
| cp -r "temp-${product}/${platform}" "content/${product}/" | |
| echo "Copied ${platform}/ folder" | |
| fi | |
| done | |
| # Cleanup cloned repo | |
| rm -rf "temp-${product}" | |
| echo "::endgroup::" | |
| done | |
| echo "" | |
| echo "=== Content structure ===" | |
| ls -la content/ | |
| - name: Build site | |
| run: hugo | |
| - name: Verify index.json | |
| if: ${{ inputs.target == 'index.json' || inputs.target == 'all' }} | |
| run: | | |
| if [ ! -f "./public/index.json" ]; then | |
| echo "::error::index.json was not generated" | |
| exit 1 | |
| fi | |
| echo "index.json size: $(wc -c < ./public/index.json) bytes" | |
| echo "Number of entries: $(grep -c '"id"' ./public/index.json || echo 0)" | |
| - name: Verify llms.txt | |
| if: ${{ inputs.target == 'llms.txt' || inputs.target == 'all' }} | |
| run: | | |
| if [ ! -f "./public/llms.txt" ]; then | |
| echo "::error::llms.txt was not generated" | |
| exit 1 | |
| fi | |
| echo "llms.txt size: $(wc -c < ./public/llms.txt) bytes" | |
| echo "--- llms.txt content ---" | |
| cat ./public/llms.txt | |
| - name: Verify llms-full.txt | |
| if: ${{ inputs.target == 'llms-full.txt' || inputs.target == 'all' }} | |
| run: | | |
| if [ ! -f "./public/llms-full.txt" ]; then | |
| echo "::error::llms-full.txt was not generated" | |
| exit 1 | |
| fi | |
| echo "llms-full.txt size: $(wc -c < ./public/llms-full.txt) bytes" | |
| - name: Set deploy target | |
| id: target | |
| run: | | |
| if [[ "${{ inputs.environment }}" == "qa" ]]; then | |
| echo "remote_dir=${{ secrets.DOCS_QA_SSH_DIR }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "remote_dir=${{ secrets.DOCS_SSH_DIR }}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Deploy index.json | |
| if: ${{ inputs.target == 'index.json' || inputs.target == 'all' }} | |
| uses: nogsantos/scp-deploy@master | |
| with: | |
| src: ./public/index.json | |
| host: ${{ secrets.DOCS_SSH_HOST }} | |
| remote: ${{ steps.target.outputs.remote_dir }} | |
| user: ${{ secrets.DOCS_SSH_USER }} | |
| key: ${{ secrets.DOCS_SSH_KEY }} | |
| - name: Deploy llms.txt | |
| if: ${{ inputs.target == 'llms.txt' || inputs.target == 'all' }} | |
| uses: nogsantos/scp-deploy@master | |
| with: | |
| src: ./public/llms.txt | |
| host: ${{ secrets.DOCS_SSH_HOST }} | |
| remote: ${{ steps.target.outputs.remote_dir }} | |
| user: ${{ secrets.DOCS_SSH_USER }} | |
| key: ${{ secrets.DOCS_SSH_KEY }} | |
| - name: Deploy llms-full.txt | |
| if: ${{ inputs.target == 'llms-full.txt' || inputs.target == 'all' }} | |
| uses: nogsantos/scp-deploy@master | |
| with: | |
| src: ./public/llms-full.txt | |
| host: ${{ secrets.DOCS_SSH_HOST }} | |
| remote: ${{ steps.target.outputs.remote_dir }} | |
| user: ${{ secrets.DOCS_SSH_USER }} | |
| key: ${{ secrets.DOCS_SSH_KEY }} |