# .github/workflows/deploy-sites.yml name: Deploy Subdirectories to GitHub Pages on: push: branches: [main, master] workflow_dispatch: permissions: contents: read pages: write id-token: write concurrency: group: pages cancel-in-progress: false jobs: discover-sites: runs-on: ubuntu-latest outputs: sites: ${{ steps.find-sites.outputs.sites }} steps: - name: Checkout uses: actions/checkout@v4 - name: Find site directories id: find-sites run: | # Find all directories containing index.html sites=() for dir in */; do if [ -f "${dir}index.html" ]; then sites+=("${dir%/}") fi done # Create JSON array and output on single line sites_json=$(printf '%s\n' "${sites[@]}" | jq -R . | jq -s -c .) echo "sites=$sites_json" >> $GITHUB_OUTPUT echo "Found sites: $sites_json" build: runs-on: ubuntu-latest needs: discover-sites strategy: matrix: site: ${{ fromJson(needs.discover-sites.outputs.sites) }} steps: - name: Checkout uses: actions/checkout@v4 - name: Prepare site build run: | mkdir -p _site/${{ matrix.site }} cp -r ${{ matrix.site }}/* _site/${{ matrix.site }}/ - name: Upload site artifact uses: actions/upload-artifact@v4 with: name: site-${{ matrix.site }} path: _site create-index: runs-on: ubuntu-latest needs: discover-sites steps: - name: Create root index run: | mkdir -p _site cat > _site/index.html << 'EOF' Sites Index

📁 Available Sites

EOF echo '${{ needs.discover-sites.outputs.sites }}' > _site/sites.json - name: Upload index artifact uses: actions/upload-artifact@v4 with: name: site-index path: _site merge-and-deploy: runs-on: ubuntu-latest needs: [discover-sites, build, create-index] steps: - name: Download all artifacts uses: actions/download-artifact@v4 with: path: _site pattern: site-* merge-multiple: true - name: Upload to GitHub Pages uses: actions/upload-pages-artifact@v3 with: path: _site - name: Deploy to GitHub Pages uses: actions/deploy-pages@v4