Skip to content

Commit

Permalink
Merge branch 'main' into DOP-4306
Browse files Browse the repository at this point in the history
  • Loading branch information
anabellabuckvar authored Feb 6, 2024
2 parents ffbeb17 + d563250 commit 1b1d2ed
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/deploy-feature-branch.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
on:
pull_request:
branches:
- main
- main
types:
- opened
- reopened
name: Initial Feature Branch Deploy
jobs:
jobs:
deploy:
permissions: write-all
runs-on: ubuntu-latest
Expand All @@ -26,12 +26,12 @@ jobs:
npm ci
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}}-queues
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
npm run deploy:feature:stack -- -c isFeatureBranch=true -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-queues
npm run deploy:feature:stack -- -c isFeatureBranch=true -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 isFeatureBranch=true -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@main
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache root node_modules
id: cache-root
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/update-feature-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ concurrency:
group: environment-stg-feature-${{ github.ref }}
cancel-in-progress: true
name: Update Feature Branch Infrastructure
jobs:
jobs:
prep-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
if: steps.filter.outputs.webhooks == 'true'
run: |
cd cdk-infra/
npm run deploy:feature:stack -- -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} \
npm run deploy:feature:stack -- -c isFeatureBranch=true -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} \
auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-webhooks
build-worker:
needs: prep-build
Expand Down Expand Up @@ -109,5 +109,5 @@ jobs:
if: steps.filter.outputs.worker == 'true'
run: |
cd cdk-infra/
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 isFeatureBranch=true -c env=stg -c customFeatureName=enhancedApp-stg-${{github.head_ref}} \
auto-builder-stack-enhancedApp-stg-${{github.head_ref}}-worker
12 changes: 10 additions & 2 deletions cdk-infra/lib/constructs/worker/worker-env-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import { IQueue } from 'aws-cdk-lib/aws-sqs';
import { StringParameter } from 'aws-cdk-lib/aws-ssm';
import { Construct } from 'constructs';
import { getCdnInvalidatorUrl } from '../../../utils/cdn';
import { getEnv, envShortToFullName, getIsEnhanced, getUseCustomBuckets, getFeatureName } from '../../../utils/env';
import {
getEnv,
envShortToFullName,
getIsEnhanced,
getUseCustomBuckets,
getFeatureName,
getIsFeatureBranch,
} from '../../../utils/env';
import { getSearchIndexFolder } from '../../../utils/search-index';
import { getSsmPathPrefix } from '../../../utils/ssm';

Expand Down Expand Up @@ -90,11 +97,12 @@ export class WorkerEnvConstruct extends Construct {
SEARCH_INDEX_FOLDER: getSearchIndexFolder(env),
ENHANCED: `${getIsEnhanced()}`,
USE_CUSTOM_BUCKETS: `${getUseCustomBuckets()}`,
FEATURE_NAME: `${getFeatureName()}`,
FEATURE_NAME: getFeatureName(),
GATSBY_TEST_SEARCH_UI: 'false',
GATSBY_SHOW_CHATBOT: gatsbyUseChatbot,
GATSBY_HIDE_UNIFIED_FOOTER_LOCALE: gatsbyHideUnifiedFooterLocale,
GATSBY_MARIAN_URL: gatsbyMarianUrl,
IS_FEATURE_BRANCH: getIsFeatureBranch(),
};
}
}
13 changes: 13 additions & 0 deletions cdk-infra/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ export function getSnootyParserVersion(): string {

return snootyParserVersion;
}

export function getIsFeatureBranch() {
checkContextInit();
const isFeatureBranch = contextVarsMap.get('isFeatureBranch');

if (!isFeatureBranch) {
console.warn('Error! The context variable isFeatureBranch is not defined.');
return '';
}

return isFeatureBranch;
}

export function getFeatureName(): string {
checkContextInit();

Expand Down
13 changes: 11 additions & 2 deletions src/job/jobHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ export abstract class JobHandler {
// completed after the Gatsby Cloud build via the SnootyBuildComplete lambda.
const { _id: jobId, user } = this.currJob;
const gatsbyCloudSiteId = await this._repoEntitlementsRepo.getGatsbySiteIdByGithubUsername(user);
if (gatsbyCloudSiteId && this.currJob.payload.jobType === 'githubPush') {
if (
gatsbyCloudSiteId &&
this.currJob.payload.jobType === 'githubPush' &&
process.env.IS_FEATURE_BRANCH !== 'true'
) {
this.logger.info(
jobId,
`User ${user} has a Gatsby Cloud site. The Autobuilder will not mark the build as completed right now.`
Expand Down Expand Up @@ -353,7 +357,12 @@ export abstract class JobHandler {

// Call Gatsby Cloud preview webhook after persistence module finishes for staging builds
const isFeaturePreviewWebhookEnabled = process.env.GATSBY_CLOUD_PREVIEW_WEBHOOK_ENABLED?.toLowerCase() === 'true';
if (key === 'persistence-module' && this.name === 'Staging' && isFeaturePreviewWebhookEnabled) {
if (
key === 'persistence-module' &&
this.name === 'Staging' &&
isFeaturePreviewWebhookEnabled &&
process.env.IS_FEATURE_BRANCH !== 'true'
) {
await this.callGatsbyCloudWebhook();
}
}
Expand Down

0 comments on commit 1b1d2ed

Please sign in to comment.