55 branches : [dev, main]
66 pull_request :
77 branches : [dev, main]
8+ workflow_dispatch :
9+ inputs :
10+ environment :
11+ description : ' Environment to deploy to'
12+ required : true
13+ default : ' development'
14+ type : choice
15+ options :
16+ - development
17+ - production
818
919# Prevent multiple concurrent deployments
1020concurrency :
1121 group : ${{ github.workflow }}-${{ github.ref }}
1222 cancel-in-progress : false
1323
1424jobs :
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-
8625 deploy-dev :
8726 name : Deploy to Development
88- needs : build
8927 runs-on : ubuntu-latest
9028 environment : Development
91- if : (github.ref == 'refs/heads/dev' || (github.event_name == 'pull_request' && github.base_ref == 'dev')) && needs.build.outputs.environment == 'Development'
29+ # Run for: dev branch pushes, PRs targeting dev, or manual dispatch to development
30+ if : |
31+ github.ref == 'refs/heads/dev' ||
32+ (github.event_name == 'pull_request' && github.base_ref == 'dev') ||
33+ (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'development')
9234 permissions :
9335 deployments : write
94- pull-requests : write # Needed to comment on PRs
36+ pull-requests : write
9537 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
38+ - name : Trigger Render Deploy
10339 id : deploy
10440 uses :
JorgeLNJunior/[email protected] 10541 with :
106- service_id : ${{ secrets .RENDER_SERVICE_ID }}
42+ service_id : ${{ vars .RENDER_SERVICE_ID }}
10743 api_key : ${{ secrets.RENDER_API_KEY }}
44+ clear_cache : false
10845 wait_deploy : true
10946 github_deployment : true
110- deployment_environment : ${{ secrets .RENDER_DEPLOY_ENVIRONMENT }}
47+ deployment_environment : ${{ vars .RENDER_DEPLOY_ENVIRONMENT }}
11148 github_token : ${{ secrets.GITHUB_TOKEN }}
11249
11350 - name : Comment on PR
11653 with :
11754 github-token : ${{ secrets.GITHUB_TOKEN }}
11855 script : |
119- const deployUrl = '${{ secrets .SITE_URL }}';
56+ const deployUrl = '${{ vars .SITE_URL }}';
12057 const environment = 'Development';
12158 const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
12259
@@ -165,29 +102,27 @@ jobs:
165102
166103 deploy-prod :
167104 name : Deploy to Production
168- needs : build
169105 runs-on : ubuntu-latest
170106 environment : Production
171- if : (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')) && needs.build.outputs.environment == 'Production'
107+ # Run for: main branch pushes, PRs targeting main, or manual dispatch to production
108+ if : |
109+ github.ref == 'refs/heads/main' ||
110+ (github.event_name == 'pull_request' && github.base_ref == 'main') ||
111+ (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'production')
172112 permissions :
173113 deployments : write
174- pull-requests : write # Needed to comment on PRs
114+ pull-requests : write
175115 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
116+ - name : Trigger Render Deploy
183117 id : deploy
184118 uses :
JorgeLNJunior/[email protected] 185119 with :
186- service_id : ${{ secrets .RENDER_SERVICE_ID }}
120+ service_id : ${{ vars .RENDER_SERVICE_ID }}
187121 api_key : ${{ secrets.RENDER_API_KEY }}
122+ clear_cache : false
188123 wait_deploy : true
189124 github_deployment : true
190- deployment_environment : ${{ secrets .RENDER_DEPLOY_ENVIRONMENT }}
125+ deployment_environment : ${{ vars .RENDER_DEPLOY_ENVIRONMENT }}
191126 github_token : ${{ secrets.GITHUB_TOKEN }}
192127
193128 - name : Comment on PR
@@ -196,7 +131,7 @@ jobs:
196131 with :
197132 github-token : ${{ secrets.GITHUB_TOKEN }}
198133 script : |
199- const deployUrl = '${{ secrets .SITE_URL }}';
134+ const deployUrl = '${{ vars .SITE_URL }}';
200135 const environment = 'Production';
201136 const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
202137
0 commit comments