From 0ae28ba58436015d14e58872c7b7976d2372c038 Mon Sep 17 00:00:00 2001 From: branberry Date: Tue, 21 Nov 2023 11:22:25 -0600 Subject: [PATCH 01/17] [DOP-4003]: Add test workflow --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e06025c0..da293d387 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,7 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '18.x' + - uses: mongodb/docs-worker-actions@main - name: Install dependencies run: npm install --dev - name: Lint From ef2d15c9301b48e46a1feb2b05127e18ed4c02d3 Mon Sep 17 00:00:00 2001 From: branberry Date: Tue, 21 Nov 2023 11:23:45 -0600 Subject: [PATCH 02/17] [DOP-4003]: Use correct path --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da293d387..2d47da3f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '18.x' - - uses: mongodb/docs-worker-actions@main + - uses: mongodb/docs-worker-actions/comment-pr@main - name: Install dependencies run: npm install --dev - name: Lint From a9dd32ca7a5fc3c27b960057a7dac6efbacdf83b Mon Sep 17 00:00:00 2001 From: branberry Date: Tue, 21 Nov 2023 11:35:33 -0600 Subject: [PATCH 03/17] [DOP-4003]: Use branch action path --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d47da3f6..8e3cf8bd5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '18.x' - - uses: mongodb/docs-worker-actions/comment-pr@main + - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 - name: Install dependencies run: npm install --dev - name: Lint From c9b8cbed8153a4e565f2ba368db196c08f54d5fe Mon Sep 17 00:00:00 2001 From: branberry Date: Tue, 21 Nov 2023 11:37:26 -0600 Subject: [PATCH 04/17] [DOP-4003]: Comment out extra steps temporarily --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e3cf8bd5..374954170 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,9 +35,9 @@ jobs: with: node-version: '18.x' - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 - - name: Install dependencies - run: npm install --dev - - name: Lint - run: npm run lint && npm run format - - name: Test - run: npm test + # - name: Install dependencies + # run: npm install --dev + # - name: Lint + # run: npm run lint && npm run format + # - name: Test + # run: npm test From 86a81d224ccf179d5df0887d8d53cae08a114b6f Mon Sep 17 00:00:00 2001 From: branberry Date: Tue, 21 Nov 2023 11:41:58 -0600 Subject: [PATCH 05/17] [DOP-4003]: Move test action --- .github/workflows/test.yml | 13 ++++++------- .github/workflows/update-feature-branch.yml | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 374954170..3e06025c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,10 +34,9 @@ jobs: - uses: actions/setup-node@v1 with: node-version: '18.x' - - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 - # - name: Install dependencies - # run: npm install --dev - # - name: Lint - # run: npm run lint && npm run format - # - name: Test - # run: npm test + - name: Install dependencies + run: npm install --dev + - name: Lint + run: npm run lint && npm run format + - name: Test + run: npm test diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index 72ebe490c..0638763ca 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -24,7 +24,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - + - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 - uses: actions/checkout@v2 - uses: dorny/paths-filter@v2 id: filter From 64b84c2d3a0b6fccabed1cddf292ddda1b9f4d58 Mon Sep 17 00:00:00 2001 From: branberry Date: Tue, 21 Nov 2023 13:17:55 -0600 Subject: [PATCH 06/17] [DOP-4003]: Add github token --- .github/workflows/update-feature-branch.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index 0638763ca..62934112c 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -25,6 +25,8 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v2 - uses: dorny/paths-filter@v2 id: filter From 00a0b713459229117d191e7696a341c9cd7a672d Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 09:16:57 -0600 Subject: [PATCH 07/17] [DOP-4003]: Add custom webhook to update feature branch for testing --- .github/workflows/update-feature-branch.yml | 10 +++++----- api/controllers/v2/github.ts | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index 62934112c..53042e84a 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -24,9 +24,7 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-2 - - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/checkout@v2 - uses: dorny/paths-filter@v2 id: filter @@ -48,8 +46,10 @@ jobs: cd cdk-infra/ npm ci npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} \ - auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks - + auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks --outputs-file outputs.json + - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Update Worker Stack if: steps.filter.outputs.worker == 'true' run: | diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index ccb205f6e..4af34c798 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,6 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { + console.log('test'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From c78f1c281a4e90ae78ab8c54ed78be417a36989a Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 09:20:56 -0600 Subject: [PATCH 08/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 4af34c798..6f48f627e 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('test'); + console.log('testing'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From 9f8022d72b3f29daa838f025590796c14e6dbade Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 09:22:14 -0600 Subject: [PATCH 09/17] [DOP-4003]: Update path filter --- .github/workflows/update-feature-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index 53042e84a..39714bb04 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -31,7 +31,7 @@ jobs: with: filters: | webhooks: - - 'api/v2/**' + - 'api/**' - 'cdk-infra/lib/constructs/api/**' - 'cdk-infra/utils/**' worker: From 463816b207f8d2979bff069d5136cf5f7300b32e Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 09:28:37 -0600 Subject: [PATCH 10/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 6f48f627e..240b571c8 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing'); + console.log('testing again'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From 9ede437a86132c55ee893ed163479ed50b0e6eea Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 09:37:32 -0600 Subject: [PATCH 11/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 240b571c8..92dc2bf13 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing again'); + console.log('testing agains'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From 955c05973ffbabfd9e90a5d00ab5ca75614c44f1 Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 09:42:20 -0600 Subject: [PATCH 12/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 92dc2bf13..60547c337 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing agains'); + console.log('testing againss'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From fc3dd8614e0880d53c6b60906128c473b7814ec7 Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 10:41:16 -0600 Subject: [PATCH 13/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 60547c337..d5dde8030 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing againss'); + console.log('testing againsss'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From 3223be54cb9882718149af28cae4a61c2baa1f8e Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 10:52:07 -0600 Subject: [PATCH 14/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index d5dde8030..79a2d4556 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing againsss'); + console.log('testing againssss'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From 40abd60d85ee1d8df0c5f0009e2264ef964dddce Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 11:00:15 -0600 Subject: [PATCH 15/17] [DOP-4003]: Add meaningless commit to trigger webhook deploy --- api/controllers/v2/github.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 79a2d4556..4097898d9 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,7 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing againssss'); + console.log('testing againsssss'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName')); From 4d91d1b2d57cd0d534379e352b6a290d7f27b766 Mon Sep 17 00:00:00 2001 From: branberry Date: Wed, 22 Nov 2023 12:31:36 -0600 Subject: [PATCH 16/17] [DOP-4003]: Move webhook comment action to correct workflow --- .github/scripts/webhook-pr-comment.js | 14 -------------- .github/workflows/deploy-feature-branch.yml | 13 +------------ .github/workflows/update-feature-branch.yml | 5 +---- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 .github/scripts/webhook-pr-comment.js diff --git a/.github/scripts/webhook-pr-comment.js b/.github/scripts/webhook-pr-comment.js deleted file mode 100644 index 19c60882d..000000000 --- a/.github/scripts/webhook-pr-comment.js +++ /dev/null @@ -1,14 +0,0 @@ -const fs = require('fs'); -const path = require('path'); -module.exports = () => { - try { - const outputsFile = fs.readFileSync('cdk-infra/outputs.json').toString(); - const outputs = JSON.parse(outputsFile); - - const webhook = Object.values(outputs[`auto-builder-stack-enhancedApp-stg-${process.env.GIT_BRANCH}-webhooks`])[0]; - return webhook; - } catch (error) { - console.log('Error occurred when retrieving Webhook URL', error); - return ''; - } -}; diff --git a/.github/workflows/deploy-feature-branch.yml b/.github/workflows/deploy-feature-branch.yml index 9e7d6d150..5567a0a04 100644 --- a/.github/workflows/deploy-feature-branch.yml +++ b/.github/workflows/deploy-feature-branch.yml @@ -30,17 +30,6 @@ jobs: npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-worker npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks --outputs-file outputs.json - name: Get Webhook URL - uses: actions/github-script@v6 - id: webhook - env: - GIT_BRANCH: ${{github.head_ref}} - with: - script: | - const script = require('./.github/scripts/webhook-pr-comment.js'); - return script() - result-encoding: string - - name: Comment on PR - if: steps.webhook.outputs.result != '' - run: gh pr comment ${{github.event.number}} --body "The URL for your feature branch webhook is ${{steps.webhook.outputs.result}}" + uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 # TODO: change branch from feature to main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/update-feature-branch.yml b/.github/workflows/update-feature-branch.yml index 39714bb04..ba672bc28 100644 --- a/.github/workflows/update-feature-branch.yml +++ b/.github/workflows/update-feature-branch.yml @@ -46,10 +46,7 @@ jobs: cd cdk-infra/ npm ci npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} \ - auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks --outputs-file outputs.json - - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks - name: Update Worker Stack if: steps.filter.outputs.worker == 'true' run: | From 0831731a8d293309d24b014627dfad0498f6fb2c Mon Sep 17 00:00:00 2001 From: branberry Date: Fri, 1 Dec 2023 09:33:28 -0600 Subject: [PATCH 17/17] [DOP-4003]: Clean up --- .github/workflows/deploy-feature-branch.yml | 2 +- api/controllers/v2/github.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy-feature-branch.yml b/.github/workflows/deploy-feature-branch.yml index 5567a0a04..764c90c83 100644 --- a/.github/workflows/deploy-feature-branch.yml +++ b/.github/workflows/deploy-feature-branch.yml @@ -30,6 +30,6 @@ jobs: npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-worker npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks --outputs-file outputs.json - name: Get Webhook URL - uses: mongodb/docs-worker-actions/comment-pr@DOP-4003 # TODO: change branch from feature to main + uses: mongodb/docs-worker-actions/comment-pr@main env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/api/controllers/v2/github.ts b/api/controllers/v2/github.ts index 4097898d9..ccb205f6e 100644 --- a/api/controllers/v2/github.ts +++ b/api/controllers/v2/github.ts @@ -59,7 +59,6 @@ async function prepGithubPushPayload( } export const TriggerBuild = async (event: APIGatewayEvent): Promise => { - console.log('testing againsssss'); const client = new mongodb.MongoClient(c.get('dbUrl')); await client.connect(); const db = client.db(c.get('dbName'));