Skip to content

Commit b9df52a

Browse files
committed
improved deployments and algolia indexing
1 parent dd86f89 commit b9df52a

File tree

2 files changed

+174
-181
lines changed

2 files changed

+174
-181
lines changed

.github/workflows/deploy.yml

Lines changed: 163 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ jobs:
2626
id: set-env
2727
run: |
2828
if [[ "${{ github.ref }}" == "refs/heads/main" ]] || [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "main" ]]; then
29-
echo "environment=production" >> $GITHUB_OUTPUT
29+
echo "environment=Production" >> $GITHUB_OUTPUT
3030
echo "SITE_URL=${{ secrets.PROD_URL }}" >> $GITHUB_ENV
3131
else
32-
echo "environment=development" >> $GITHUB_OUTPUT
32+
echo "environment=Development" >> $GITHUB_OUTPUT
3333
echo "SITE_URL=${{ secrets.DEV_URL }}" >> $GITHUB_ENV
3434
fi
3535
@@ -83,162 +83,164 @@ jobs:
8383
path: build/
8484
retention-days: 1
8585

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/render-deploy@v1.4.5
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/render-deploy@v1.4.5
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-
# }
86+
deploy-dev:
87+
name: Deploy to Development
88+
needs: build
89+
runs-on: ubuntu-latest
90+
environment: Development
91+
if: (github.ref == 'refs/heads/dev' || (github.event_name == 'pull_request' && github.base_ref == 'dev')) && needs.build.outputs.environment == 'Development'
92+
permissions:
93+
deployments: write
94+
pull-requests: write # Needed to comment on PRs
95+
steps:
96+
- name: Download build artifacts
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: build-Development
100+
path: build/
101+
102+
- name: Deploy to Render Dev
103+
id: deploy
104+
uses: JorgeLNJunior/render-deploy@v1.4.5
105+
with:
106+
service_id: ${{ vars.RENDER_SERVICE_ID }}
107+
api_key: ${{ secrets.RENDER_API_KEY }}
108+
wait_deploy: true
109+
github_deployment: true
110+
deployment_environment: ${{ vars.RENDER_DEPLOY_ENVIRONMENT }}
111+
github_token: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Comment on PR
114+
if: github.event_name == 'pull_request'
115+
uses: actions/github-script@v7
116+
with:
117+
github-token: ${{ secrets.GITHUB_TOKEN }}
118+
script: |
119+
const deployUrl = '${{ vars.SITE_URL }}';
120+
const environment = 'Development';
121+
const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
122+
123+
const comment = `${commentIdentifier}
124+
### 🚀 Preview Deployment Ready!
125+
126+
Your changes have been successfully deployed to the ${environment.toLowerCase()} environment.
127+
128+
**Preview URL:** ${deployUrl}
129+
130+
| Status | Environment | Commit | Time |
131+
|--------|-------------|--------|------|
132+
| ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |
133+
134+
---
135+
<sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;
136+
137+
// Find existing comment
138+
const { data: comments } = await github.rest.issues.listComments({
139+
owner: context.repo.owner,
140+
repo: context.repo.repo,
141+
issue_number: context.issue.number,
142+
});
143+
144+
const botComment = comments.find(comment =>
145+
comment.body.includes(commentIdentifier)
146+
);
147+
148+
if (botComment) {
149+
// Update existing comment
150+
await github.rest.issues.updateComment({
151+
owner: context.repo.owner,
152+
repo: context.repo.repo,
153+
comment_id: botComment.id,
154+
body: comment
155+
});
156+
} else {
157+
// Create new comment
158+
await github.rest.issues.createComment({
159+
issue_number: context.issue.number,
160+
owner: context.repo.owner,
161+
repo: context.repo.repo,
162+
body: comment
163+
});
164+
}
165+
166+
deploy-prod:
167+
name: Deploy to Production
168+
needs: build
169+
runs-on: ubuntu-latest
170+
environment: Production
171+
if: (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')) && needs.build.outputs.environment == 'Production'
172+
permissions:
173+
deployments: write
174+
pull-requests: write # Needed to comment on PRs
175+
steps:
176+
- name: Download build artifacts
177+
uses: actions/download-artifact@v4
178+
with:
179+
name: build-Production
180+
path: build/
181+
182+
- name: Deploy to Render Prod
183+
id: deploy
184+
uses: JorgeLNJunior/render-deploy@v1.4.5
185+
with:
186+
service_id: ${{ vars.RENDER_SERVICE_ID }}
187+
api_key: ${{ secrets.RENDER_API_KEY }}
188+
wait_deploy: true
189+
github_deployment: true
190+
deployment_environment: ${{ vars.RENDER_DEPLOY_ENVIRONMENT }}
191+
github_token: ${{ secrets.GITHUB_TOKEN }}
192+
193+
- name: Comment on PR
194+
if: github.event_name == 'pull_request'
195+
uses: actions/github-script@v7
196+
with:
197+
github-token: ${{ secrets.GITHUB_TOKEN }}
198+
script: |
199+
const deployUrl = '${{ vars.SITE_URL }}';
200+
const environment = 'Production';
201+
const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
202+
203+
const comment = `${commentIdentifier}
204+
### 🚀 Production Preview Deployment Ready!
205+
206+
Your changes have been successfully deployed to the ${environment.toLowerCase()} preview environment.
207+
208+
**Preview URL:** ${deployUrl}
209+
210+
| Status | Environment | Commit | Time |
211+
|--------|-------------|--------|------|
212+
| ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |
213+
214+
⚠️ **Note:** This is a preview deployment for the production environment. The actual production deployment will occur after merge.
215+
216+
---
217+
<sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;
218+
219+
// Find existing comment
220+
const { data: comments } = await github.rest.issues.listComments({
221+
owner: context.repo.owner,
222+
repo: context.repo.repo,
223+
issue_number: context.issue.number,
224+
});
225+
226+
const botComment = comments.find(comment =>
227+
comment.body.includes(commentIdentifier)
228+
);
229+
230+
if (botComment) {
231+
// Update existing comment
232+
await github.rest.issues.updateComment({
233+
owner: context.repo.owner,
234+
repo: context.repo.repo,
235+
comment_id: botComment.id,
236+
body: comment
237+
});
238+
} else {
239+
// Create new comment
240+
await github.rest.issues.createComment({
241+
issue_number: context.issue.number,
242+
owner: context.repo.owner,
243+
repo: context.repo.repo,
244+
body: comment
245+
});
246+
}

0 commit comments

Comments
 (0)