Deploy IOTA-Names Docs to Vercel #34
Workflow file for this run
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 IOTA-Names Docs to Vercel | |
| on: | |
| push: | |
| branches: [ main, develop, devx/deploy-docs-vercel ] | |
| paths: | |
| - "documentation/**" | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: "vercel environment: preview or production" | |
| required: true | |
| default: "preview" | |
| env: | |
| DOCS_DIR: documentation | |
| VERCEL_ENVIRONMENT: ${{ github.event.inputs.environment || 'preview' }} | |
| VERCEL_TELEMETRY_DISABLED: "1" | |
| jobs: | |
| vercel-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| deployments: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| # Force production when building from main | |
| - name: Force VERCEL_ENVIRONMENT=production on main | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| run: echo "VERCEL_ENVIRONMENT=production" >> "$GITHUB_ENV" | |
| # Link Vercel project locally (no vercel pull, no local build) | |
| - name: Link Vercel project | |
| run: | | |
| set -e | |
| mkdir -p "${DOCS_DIR}/.vercel" | |
| cat > "${DOCS_DIR}/.vercel/project.json" <<JSON | |
| { "orgId": "${VERCEL_ORG_ID}", "projectId": "${IOTA_NAMES_DOCS_VERCEL_PROJECT_ID}" } | |
| JSON | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| IOTA_NAMES_DOCS_VERCEL_PROJECT_ID: ${{ secrets.IOTA_NAMES_DOCS_VERCEL_PROJECT_ID }} | |
| # Cloud build on Vercel (no local build) | |
| - name: Deploy (cloud build) | |
| run: | | |
| if [ "$VERCEL_ENVIRONMENT" = "production" ]; then | |
| npx --yes vercel@latest deploy --yes --prod \ | |
| --token "${VERCEL_TOKEN}" \ | |
| --scope "${VERCEL_SCOPE}" \ | |
| --cwd "${DOCS_DIR}" | |
| else | |
| npx --yes vercel@latest deploy --yes \ | |
| --token "${VERCEL_TOKEN}" \ | |
| --scope "${VERCEL_SCOPE}" \ | |
| --cwd "${DOCS_DIR}" | |
| fi | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }} |