Skip to content

Commit 313e76b

Browse files
MichaelWalker-gitMichael Trangithub-actionskrokoko
authored
feat(documentation_website): Automated deployment (#281)
* feat: add automated deployment * chore: self mutation Signed-off-by: github-actions <[email protected]> * feat: make changes to projen manifest file * feat: make changes to projen manifest file * fix: projenrc for test deployment pull request * fix: add npm ignore and gitignore patterns * fix(test): wrong yarn build directory * fix(test): wrong yarn build directory * fix(test): wrong yarn build directory * fix(test): wrong yarn build directory * fix(test): wrong yarn build directory --------- Signed-off-by: github-actions <[email protected]> Co-authored-by: Michael Tran <[email protected]> Co-authored-by: github-actions <[email protected]> Co-authored-by: Alain Krok <[email protected]>
1 parent e61f9f0 commit 313e76b

File tree

7 files changed

+127
-0
lines changed

7 files changed

+127
-0
lines changed

.gitattributes

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/deploydocs.yml

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/testdeployment.yml

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.npmignore

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projen/files.json

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

+70
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313
import { ProjenStruct, Struct } from '@mrgrain/jsii-struct-builder';
1414
import { JsonPatch, awscdk } from 'projen';
15+
import { JobPermission } from 'projen/lib/github/workflows-model';
1516
import { NpmAccess } from 'projen/lib/javascript';
1617
import {
1718
buildMeritBadgerWorkflow,
@@ -103,6 +104,9 @@ const project = new awscdk.AwsCdkConstructLibrary({
103104
'!.ort.yml',
104105
'.idea',
105106
'.vscode',
107+
'website/build',
108+
'website/node_modules',
109+
'website/.docusaurus',
106110
],
107111
stability: 'experimental',
108112
sampleCode: false,
@@ -138,6 +142,71 @@ project.github?.actions.set('peter-evans/create-issue-from-file@v4', 'peter-evan
138142
project.github?.actions.set('peter-evans/create-pull-request@v4', 'peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54');
139143
project.github?.actions.set('peter-evans/create-pull-request@v5', 'peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38');
140144
project.github?.actions.set('aws-actions/[email protected]', 'aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502');
145+
// docusaurus add specific overrides
146+
147+
project.github?.actions.set('peaceiris/actions-gh-pages@v3', 'peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847');
148+
project;
149+
const deployDocsWorkflow = project.github?.addWorkflow('DeployDocs');
150+
if (deployDocsWorkflow) {
151+
deployDocsWorkflow.on({
152+
push: {
153+
branches: ['main'],
154+
},
155+
});
156+
157+
project.github?.actions.set('peaceiris/actions-gh-pages@v3', 'peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847');
158+
159+
deployDocsWorkflow.addJobs({
160+
deploy: {
161+
permissions: {
162+
contents: JobPermission.WRITE,
163+
},
164+
runsOn: ['ubuntu-latest'],
165+
steps: [
166+
{ uses: 'actions/checkout@v3' },
167+
{
168+
uses: 'actions/setup-node@v3',
169+
with: { 'node-version': '18' },
170+
},
171+
{ run: 'cd website; yarn install --frozen-lockfile;' },
172+
{
173+
uses: 'peaceiris/actions-gh-pages@v3',
174+
with: {
175+
github_token: '${{ secrets.GITHUB_TOKEN }}',
176+
publish_dir: './website/build',
177+
user_name: 'github-actions[bot]',
178+
user_email: '41898282+github-actions[bot]@users.noreply.github.com',
179+
},
180+
},
181+
],
182+
},
183+
});
184+
}
185+
186+
const testDeploymentWorkflow = project.github?.addWorkflow('TestDeployment');
187+
188+
if (testDeploymentWorkflow) {
189+
testDeploymentWorkflow.on({
190+
pullRequest: {
191+
branches: ['main'],
192+
},
193+
});
194+
195+
testDeploymentWorkflow.addJobs({
196+
test_deploy: {
197+
permissions: {
198+
contents: JobPermission.WRITE,
199+
},
200+
runsOn: ['ubuntu-latest'],
201+
steps: [
202+
{ uses: 'actions/checkout@v3', with: { 'fetch-depth': '0' } },
203+
{ uses: 'actions/setup-node@v3', with: { 'node-version': '18', 'cache': 'yarn' } },
204+
{ run: 'cd website; yarn install --frozen-lockfile' },
205+
{ run: 'cd website; pwd; npx docusaurus build', name: 'Test build website' },
206+
],
207+
},
208+
});
209+
}
141210

142211
// We don't want to package certain things
143212
project.npmignore?.addPatterns(
@@ -157,6 +226,7 @@ project.npmignore?.addPatterns(
157226
'tsconfig.dev.json',
158227
'yarn.lock',
159228
'/apidocs/',
229+
'website/',
160230
);
161231

162232
// Add License header automatically

0 commit comments

Comments
 (0)