Skip to content

Commit 82b9bf9

Browse files
committed
fixed single builds
1 parent fea7fbe commit 82b9bf9

File tree

3 files changed

+418
-34
lines changed

3 files changed

+418
-34
lines changed

.github/workflows/deploy.yml

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
name: Deploy to Render
2+
3+
on:
4+
push:
5+
branches: [dev, main]
6+
pull_request:
7+
branches: [dev, main]
8+
9+
# Prevent multiple concurrent deployments
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: false
13+
14+
jobs:
15+
build:
16+
name: Build Documentation
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 90
19+
outputs:
20+
environment: ${{ steps.set-env.outputs.environment }}
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Determine environment
26+
id: set-env
27+
run: |
28+
if [[ "${{ github.ref }}" == "refs/heads/main" ]] || [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "main" ]]; then
29+
echo "environment=production" >> $GITHUB_OUTPUT
30+
echo "SITE_URL=${{ secrets.PROD_URL }}" >> $GITHUB_ENV
31+
else
32+
echo "environment=development" >> $GITHUB_OUTPUT
33+
echo "SITE_URL=${{ secrets.DEV_URL }}" >> $GITHUB_ENV
34+
fi
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '18'
40+
cache: 'npm'
41+
42+
- name: Cache Docusaurus build
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
.docusaurus
47+
.cache
48+
build/.cache
49+
key: ${{ runner.os }}-docusaurus-build-${{ steps.set-env.outputs.environment }}-${{ hashFiles('**/package-lock.json', '**/docusaurus.config.js', 'docs/**/*.md', 'docs/**/*.mdx') }}
50+
restore-keys: |
51+
${{ runner.os }}-docusaurus-build-${{ steps.set-env.outputs.environment }}-
52+
${{ runner.os }}-docusaurus-build-
53+
54+
- name: Cache webpack
55+
uses: actions/cache@v4
56+
with:
57+
path: node_modules/.cache
58+
key: ${{ runner.os }}-webpack-${{ steps.set-env.outputs.environment }}-${{ hashFiles('**/package-lock.json') }}
59+
restore-keys: |
60+
${{ runner.os }}-webpack-${{ steps.set-env.outputs.environment }}-
61+
${{ runner.os }}-webpack-
62+
63+
- name: Install dependencies
64+
run: npm ci
65+
66+
- name: Build site
67+
run: npm run build
68+
env:
69+
RENDER_EXTERNAL_URL: ${{ env.SITE_URL }}
70+
71+
- name: Validate build output
72+
run: |
73+
if [ ! -d "build" ]; then
74+
echo "❌ Build directory not found!"
75+
exit 1
76+
fi
77+
echo "✅ Build directory exists with $(find build -type f | wc -l) files"
78+
79+
- name: Upload build artifacts
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: build-${{ steps.set-env.outputs.environment }}
83+
path: build/
84+
retention-days: 1
85+
86+
# deploy-dev:
87+
# name: Deploy to Development
88+
# needs: build
89+
# runs-on: ubuntu-latest
90+
# if: (github.ref == 'refs/heads/dev' || (github.event_name == 'pull_request' && github.base_ref == 'dev')) && needs.build.outputs.environment == 'development'
91+
# permissions:
92+
# deployments: write
93+
# pull-requests: write # Needed to comment on PRs
94+
# steps:
95+
# - name: Download build artifacts
96+
# uses: actions/download-artifact@v4
97+
# with:
98+
# name: build-development
99+
# path: build/
100+
101+
# - name: Deploy to Render Dev
102+
# id: deploy
103+
# uses: JorgeLNJunior/[email protected]
104+
# with:
105+
# service_id: ${{ secrets.RENDER_SERVICE_ID_DEV }}
106+
# api_key: ${{ secrets.RENDER_API_KEY }}
107+
# wait_deploy: true
108+
# github_deployment: true
109+
# deployment_environment: ${{ secrets.RENDER_DEPLOY_ENVIRONMENT_DEV }}
110+
# github_token: ${{ secrets.GITHUB_TOKEN }}
111+
112+
# - name: Comment on PR
113+
# if: github.event_name == 'pull_request'
114+
# uses: actions/github-script@v7
115+
# with:
116+
# github-token: ${{ secrets.GITHUB_TOKEN }}
117+
# script: |
118+
# const deployUrl = '${{ secrets.DEV_URL }}';
119+
# const environment = 'Development';
120+
# const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
121+
122+
# const comment = `${commentIdentifier}
123+
# ### 🚀 Preview Deployment Ready!
124+
125+
# Your changes have been successfully deployed to the ${environment.toLowerCase()} environment.
126+
127+
# **Preview URL:** ${deployUrl}
128+
129+
# | Status | Environment | Commit | Time |
130+
# |--------|-------------|--------|------|
131+
# | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |
132+
133+
# ---
134+
# <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;
135+
136+
# // Find existing comment
137+
# const { data: comments } = await github.rest.issues.listComments({
138+
# owner: context.repo.owner,
139+
# repo: context.repo.repo,
140+
# issue_number: context.issue.number,
141+
# });
142+
143+
# const botComment = comments.find(comment =>
144+
# comment.body.includes(commentIdentifier)
145+
# );
146+
147+
# if (botComment) {
148+
# // Update existing comment
149+
# await github.rest.issues.updateComment({
150+
# owner: context.repo.owner,
151+
# repo: context.repo.repo,
152+
# comment_id: botComment.id,
153+
# body: comment
154+
# });
155+
# } else {
156+
# // Create new comment
157+
# await github.rest.issues.createComment({
158+
# issue_number: context.issue.number,
159+
# owner: context.repo.owner,
160+
# repo: context.repo.repo,
161+
# body: comment
162+
# });
163+
# }
164+
165+
# deploy-prod:
166+
# name: Deploy to Production
167+
# needs: build
168+
# runs-on: ubuntu-latest
169+
# if: (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')) && needs.build.outputs.environment == 'production'
170+
# permissions:
171+
# deployments: write
172+
# pull-requests: write # Needed to comment on PRs
173+
# steps:
174+
# - name: Download build artifacts
175+
# uses: actions/download-artifact@v4
176+
# with:
177+
# name: build-production
178+
# path: build/
179+
180+
# - name: Deploy to Render Prod
181+
# id: deploy
182+
# uses: JorgeLNJunior/[email protected]
183+
# with:
184+
# service_id: ${{ secrets.RENDER_SERVICE_ID_PROD }}
185+
# api_key: ${{ secrets.RENDER_API_KEY }}
186+
# wait_deploy: true
187+
# github_deployment: true
188+
# deployment_environment: ${{ secrets.RENDER_DEPLOY_ENVIRONMENT_PROD }}
189+
# github_token: ${{ secrets.GITHUB_TOKEN }}
190+
191+
# - name: Comment on PR
192+
# if: github.event_name == 'pull_request'
193+
# uses: actions/github-script@v7
194+
# with:
195+
# github-token: ${{ secrets.GITHUB_TOKEN }}
196+
# script: |
197+
# const deployUrl = '${{ secrets.PROD_URL }}';
198+
# const environment = 'Production';
199+
# const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
200+
201+
# const comment = `${commentIdentifier}
202+
# ### 🚀 Production Preview Deployment Ready!
203+
204+
# Your changes have been successfully deployed to the ${environment.toLowerCase()} preview environment.
205+
206+
# **Preview URL:** ${deployUrl}
207+
208+
# | Status | Environment | Commit | Time |
209+
# |--------|-------------|--------|------|
210+
# | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |
211+
212+
# ⚠️ **Note:** This is a preview deployment for the production environment. The actual production deployment will occur after merge.
213+
214+
# ---
215+
# <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;
216+
217+
# // Find existing comment
218+
# const { data: comments } = await github.rest.issues.listComments({
219+
# owner: context.repo.owner,
220+
# repo: context.repo.repo,
221+
# issue_number: context.issue.number,
222+
# });
223+
224+
# const botComment = comments.find(comment =>
225+
# comment.body.includes(commentIdentifier)
226+
# );
227+
228+
# if (botComment) {
229+
# // Update existing comment
230+
# await github.rest.issues.updateComment({
231+
# owner: context.repo.owner,
232+
# repo: context.repo.repo,
233+
# comment_id: botComment.id,
234+
# body: comment
235+
# });
236+
# } else {
237+
# // Create new comment
238+
# await github.rest.issues.createComment({
239+
# issue_number: context.issue.number,
240+
# owner: context.repo.owner,
241+
# repo: context.repo.repo,
242+
# body: comment
243+
# });
244+
# }

0 commit comments

Comments
 (0)