Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
244 changes: 244 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
name: Deploy to Render

on:
push:
branches: [dev, main]
pull_request:
branches: [dev, main]

# Prevent multiple concurrent deployments
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
name: Build Documentation
runs-on: ubuntu-latest
timeout-minutes: 90
outputs:
environment: ${{ steps.set-env.outputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Determine environment
id: set-env
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]] || [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "main" ]]; then
echo "environment=production" >> $GITHUB_OUTPUT
echo "SITE_URL=${{ secrets.PROD_URL }}" >> $GITHUB_ENV
else
echo "environment=development" >> $GITHUB_OUTPUT
echo "SITE_URL=${{ secrets.DEV_URL }}" >> $GITHUB_ENV
fi

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'

- name: Cache Docusaurus build
uses: actions/cache@v4
with:
path: |
.docusaurus
.cache
build/.cache
key: ${{ runner.os }}-docusaurus-build-${{ steps.set-env.outputs.environment }}-${{ hashFiles('**/package-lock.json', '**/docusaurus.config.js', 'docs/**/*.md', 'docs/**/*.mdx') }}
restore-keys: |
${{ runner.os }}-docusaurus-build-${{ steps.set-env.outputs.environment }}-
${{ runner.os }}-docusaurus-build-

- name: Cache webpack
uses: actions/cache@v4
with:
path: node_modules/.cache
key: ${{ runner.os }}-webpack-${{ steps.set-env.outputs.environment }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-webpack-${{ steps.set-env.outputs.environment }}-
${{ runner.os }}-webpack-

- name: Install dependencies
run: npm ci

- name: Build site
run: npm run build
env:
RENDER_EXTERNAL_URL: ${{ env.SITE_URL }}

- name: Validate build output
run: |
if [ ! -d "build" ]; then
echo "❌ Build directory not found!"
exit 1
fi
echo "✅ Build directory exists with $(find build -type f | wc -l) files"

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-${{ steps.set-env.outputs.environment }}
path: build/
retention-days: 1

# deploy-dev:
# name: Deploy to Development
# needs: build
# runs-on: ubuntu-latest
# if: (github.ref == 'refs/heads/dev' || (github.event_name == 'pull_request' && github.base_ref == 'dev')) && needs.build.outputs.environment == 'development'
# permissions:
# deployments: write
# pull-requests: write # Needed to comment on PRs
# steps:
# - name: Download build artifacts
# uses: actions/download-artifact@v4
# with:
# name: build-development
# path: build/

# - name: Deploy to Render Dev
# id: deploy
# uses: JorgeLNJunior/[email protected]
# with:
# service_id: ${{ secrets.RENDER_SERVICE_ID_DEV }}
# api_key: ${{ secrets.RENDER_API_KEY }}
# wait_deploy: true
# github_deployment: true
# deployment_environment: ${{ secrets.RENDER_DEPLOY_ENVIRONMENT_DEV }}
# github_token: ${{ secrets.GITHUB_TOKEN }}

# - name: Comment on PR
# if: github.event_name == 'pull_request'
# uses: actions/github-script@v7
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const deployUrl = '${{ secrets.DEV_URL }}';
# const environment = 'Development';
# const commentIdentifier = `<!-- deployment-bot:${environment} -->`;

# const comment = `${commentIdentifier}
# ### 🚀 Preview Deployment Ready!

# Your changes have been successfully deployed to the ${environment.toLowerCase()} environment.

# **Preview URL:** ${deployUrl}

# | Status | Environment | Commit | Time |
# |--------|-------------|--------|------|
# | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |

# ---
# <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;

# // Find existing comment
# const { data: comments } = await github.rest.issues.listComments({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: context.issue.number,
# });

# const botComment = comments.find(comment =>
# comment.body.includes(commentIdentifier)
# );

# if (botComment) {
# // Update existing comment
# await github.rest.issues.updateComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# comment_id: botComment.id,
# body: comment
# });
# } else {
# // Create new comment
# await github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: comment
# });
# }

# deploy-prod:
# name: Deploy to Production
# needs: build
# runs-on: ubuntu-latest
# if: (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')) && needs.build.outputs.environment == 'production'
# permissions:
# deployments: write
# pull-requests: write # Needed to comment on PRs
# steps:
# - name: Download build artifacts
# uses: actions/download-artifact@v4
# with:
# name: build-production
# path: build/

# - name: Deploy to Render Prod
# id: deploy
# uses: JorgeLNJunior/[email protected]
# with:
# service_id: ${{ secrets.RENDER_SERVICE_ID_PROD }}
# api_key: ${{ secrets.RENDER_API_KEY }}
# wait_deploy: true
# github_deployment: true
# deployment_environment: ${{ secrets.RENDER_DEPLOY_ENVIRONMENT_PROD }}
# github_token: ${{ secrets.GITHUB_TOKEN }}

# - name: Comment on PR
# if: github.event_name == 'pull_request'
# uses: actions/github-script@v7
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# script: |
# const deployUrl = '${{ secrets.PROD_URL }}';
# const environment = 'Production';
# const commentIdentifier = `<!-- deployment-bot:${environment} -->`;

# const comment = `${commentIdentifier}
# ### 🚀 Production Preview Deployment Ready!

# Your changes have been successfully deployed to the ${environment.toLowerCase()} preview environment.

# **Preview URL:** ${deployUrl}

# | Status | Environment | Commit | Time |
# |--------|-------------|--------|------|
# | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |

# ⚠️ **Note:** This is a preview deployment for the production environment. The actual production deployment will occur after merge.

# ---
# <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;

# // Find existing comment
# const { data: comments } = await github.rest.issues.listComments({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: context.issue.number,
# });

# const botComment = comments.find(comment =>
# comment.body.includes(commentIdentifier)
# );

# if (botComment) {
# // Update existing comment
# await github.rest.issues.updateComment({
# owner: context.repo.owner,
# repo: context.repo.repo,
# comment_id: botComment.id,
# body: comment
# });
# } else {
# // Create new comment
# await github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: comment
# });
# }
Loading