Merge pull request #43 from vistalabs-org/deploy #4
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
| name: Deploy Documentation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'docs/**' | |
| - 'hackagent/**' | |
| - '.github/workflows/docs.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: "cloudflare-pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: 'docs/package-lock.json' | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Setup Poetry | |
| uses: abatilo/actions-poetry@v4.0.0 | |
| with: | |
| poetry-version: '1.8.3' | |
| - name: Configure Poetry | |
| run: | | |
| poetry config virtualenvs.create true | |
| poetry config virtualenvs.in-project true | |
| - name: Cache Poetry dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .venv | |
| key: poetry-${{ hashFiles('**/poetry.lock') }} | |
| - name: Install Python dependencies | |
| run: poetry install --with docs | |
| - name: Install Node.js dependencies | |
| run: | | |
| cd docs | |
| npm ci | |
| - name: Generate API documentation | |
| run: poetry run python docs/scripts/generate_docs.py --current | |
| - name: Build documentation | |
| run: | | |
| cd docs | |
| npm run build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docs-build | |
| path: docs/build | |
| retention-days: 1 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: docs-build | |
| path: docs/build | |
| - name: Setup Node.js for Wrangler | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Wrangler | |
| run: npm install -g wrangler | |
| - name: Create Cloudflare Pages project if it doesn't exist | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| PROJECT_NAME: ${{ secrets.CLOUDFLARE_PROJECT_NAME || 'hackagent-docs' }} | |
| run: | | |
| # Check if project exists, create if it doesn't | |
| if ! wrangler pages project list | grep -q "$PROJECT_NAME"; then | |
| echo "Creating Cloudflare Pages project: $PROJECT_NAME" | |
| wrangler pages project create "$PROJECT_NAME" --compatibility-date 2024-01-01 | |
| else | |
| echo "Project $PROJECT_NAME already exists" | |
| fi | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/pages-action@v1 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME || 'hackagent-docs' }} | |
| directory: docs/build | |
| gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
| wranglerVersion: '3' |