From 1ac8f0f73261992cad18202205bbf8cfd34301fe Mon Sep 17 00:00:00 2001 From: Hsu Zhong Jun <27919917+dcshzj@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:57:33 +0800 Subject: [PATCH 1/3] chore: remove extra and unused submodules (#1031) --- kishore-test-dev-emil/kishore-test-dev-emil | 1 - pa-corp/pa-corp | 1 - 2 files changed, 2 deletions(-) delete mode 160000 kishore-test-dev-emil/kishore-test-dev-emil delete mode 160000 pa-corp/pa-corp diff --git a/kishore-test-dev-emil/kishore-test-dev-emil b/kishore-test-dev-emil/kishore-test-dev-emil deleted file mode 160000 index 3478fce70..000000000 --- a/kishore-test-dev-emil/kishore-test-dev-emil +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3478fce70fb081468815b53345484e4afed28e3e diff --git a/pa-corp/pa-corp b/pa-corp/pa-corp deleted file mode 160000 index 1c144c50e..000000000 --- a/pa-corp/pa-corp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1c144c50e84907f20200221e375973c01fd82669 From 169b004c1a7e63546679bc1125bbedb0f5cd9012 Mon Sep 17 00:00:00 2001 From: Kishore <42832651+kishore03109@users.noreply.github.com> Date: Thu, 16 Nov 2023 12:54:57 +0800 Subject: [PATCH 2/3] fix(siteCreate): add redirect rules (#1036) * fix(siteCreate): add redirect rules * fix(amplify): fix release branch issue --- src/services/identity/DeploymentClient.ts | 62 +++++++++++++++++---- src/services/identity/DeploymentsService.ts | 35 ++++++++++-- 2 files changed, 79 insertions(+), 18 deletions(-) diff --git a/src/services/identity/DeploymentClient.ts b/src/services/identity/DeploymentClient.ts index 09a13594a..eb7c8598d 100644 --- a/src/services/identity/DeploymentClient.ts +++ b/src/services/identity/DeploymentClient.ts @@ -13,6 +13,9 @@ import { ListJobsCommand, ListJobsCommandOutput, JobSummary, + StartJobCommand, + StartJobCommandOutput, + StartJobCommandInput, } from "@aws-sdk/client-amplify" import { ResultAsync, errAsync, fromPromise, okAsync } from "neverthrow" @@ -77,19 +80,54 @@ class DeploymentClient { this.amplifyClient.send(new ListJobsCommand({ appId, branchName })) ) as ResultAsync - generateCreateAppInput = ( - repoName: string, + sendStartJobCommand = (options: StartJobCommandInput) => + wrap(this.amplifyClient.send(new StartJobCommand(options))) as ResultAsync< + StartJobCommandOutput, + AmplifyError + > + + generateCreateAppInput = ({ + appName, + repoName, + repoUrl, + isStagingLite, + }: { + appName: string repoUrl: string - ): CreateAppCommandInput => ({ - name: repoName, - accessToken: SYSTEM_GITHUB_TOKEN, - repository: repoUrl, - buildSpec: AMPLIFY_BUILD_SPEC, - environmentVariables: { - JEKYLL_ENV: "development", - }, - customRules: [{ source: "/<*>", target: "/404.html", status: "404" }], - }) + repoName: string + isStagingLite: boolean + }): CreateAppCommandInput => { + const stgLiteRedirectRules = [ + { + source: "/files/<*>", + target: `https://raw.githubusercontent.com/isomerpages/${repoName}/staging/files/<*>`, + status: "200", + }, + { + source: "/images/<*>", + target: `https://raw.githubusercontent.com/isomerpages/${repoName}/staging/images/<*>`, + status: "200", + }, + ] + const defaultRedirectRules = [ + { source: "/<*>", target: "/404.html", status: "404" }, + ] + + const redirectRules = isStagingLite + ? [...stgLiteRedirectRules, ...defaultRedirectRules] + : defaultRedirectRules + + return { + name: appName, + accessToken: SYSTEM_GITHUB_TOKEN, + repository: repoUrl, + buildSpec: AMPLIFY_BUILD_SPEC, + environmentVariables: { + JEKYLL_ENV: "development", + }, + customRules: redirectRules, + } + } generateCreateBranchInput = ( appId: string, diff --git a/src/services/identity/DeploymentsService.ts b/src/services/identity/DeploymentsService.ts index 9b2dda902..ee4924e9f 100644 --- a/src/services/identity/DeploymentsService.ts +++ b/src/services/identity/DeploymentsService.ts @@ -69,7 +69,7 @@ class DeploymentsService { return this.create({ stagingUrl: Brand.fromString( - `https://staging.${amplifyStagingLiteResult.value.defaultDomain}` + `https://staging-lite.${amplifyStagingLiteResult.value.defaultDomain}` ), productionUrl: Brand.fromString( `https://master.${amplifyStagingResult.value.defaultDomain}` @@ -98,15 +98,17 @@ class DeploymentsService { createAmplifyAppOnAws = async ( repoName: string, appName: string, - createStagingLite: boolean + isStagingLite: boolean ): Promise> => { const repoUrl = `https://github.com/isomerpages/${repoName}` logger.info(`PublishToAmplify ${repoUrl}`) - const createAppOptions = this.deploymentClient.generateCreateAppInput( + const createAppOptions = this.deploymentClient.generateCreateAppInput({ appName, - repoUrl - ) + repoUrl, + repoName, + isStagingLite, + }) // 1. Create Amplify app return this.deploymentClient .sendCreateApp(createAppOptions) @@ -152,17 +154,38 @@ class DeploymentsService { ) // 3. Create branches - if (createStagingLite) { + if (isStagingLite) { return this.deploymentClient .sendCreateBranch(createStagingLiteBranchInput) + .andThen(() => + this.deploymentClient.sendStartJobCommand({ + appId: amplifyInfo.id, + branchName: "staging-lite", + jobType: "RELEASE", + }) + ) .map(() => amplifyInfo) } return this.deploymentClient .sendCreateBranch(createMasterBranchInput) + .andThen(() => + this.deploymentClient.sendStartJobCommand({ + appId: amplifyInfo.id, + branchName: "master", + jobType: "RELEASE", + }) + ) .map(() => amplifyInfo) .andThen(() => this.deploymentClient .sendCreateBranch(createStagingBranchInput) + .andThen(() => + this.deploymentClient.sendStartJobCommand({ + appId: amplifyInfo.id, + branchName: "staging", + jobType: "RELEASE", + }) + ) .map(() => amplifyInfo) ) }) From e49c1bda86d6fc3aad95fdd05a19aadac408a61d Mon Sep 17 00:00:00 2001 From: Kishore <42832651+kishore03109@users.noreply.github.com> Date: Thu, 16 Nov 2023 18:57:09 +0800 Subject: [PATCH 3/3] 0.55.0 --- CHANGELOG.md | 10 +++++++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 414a6b5f7..c43a7c116 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [v0.55.0](https://github.com/isomerpages/isomercms-backend/compare/v0.54.0...v0.55.0) + +- fix(siteCreate): add redirect rules [`#1036`](https://github.com/isomerpages/isomercms-backend/pull/1036) +- chore: remove extra and unused submodules [`#1031`](https://github.com/isomerpages/isomercms-backend/pull/1031) +- release/0.54.0 [`#1033`](https://github.com/isomerpages/isomercms-backend/pull/1033) + #### [v0.54.0](https://github.com/isomerpages/isomercms-backend/compare/v0.53.0...v0.54.0) +> 14 November 2023 + - fix: use cTimeMs instead of birthtime due to EFS [`#1035`](https://github.com/isomerpages/isomercms-backend/pull/1035) - fix(pagination): total length [`#1032`](https://github.com/isomerpages/isomercms-backend/pull/1032) - fix(staging-lite): apps were created for wrong br [`#1014`](https://github.com/isomerpages/isomercms-backend/pull/1014) @@ -13,7 +21,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - fix(pagination): images fix pagination [`#1026`](https://github.com/isomerpages/isomercms-backend/pull/1026) - fix(media): change media sorting to addedTime descending [`#1019`](https://github.com/isomerpages/isomercms-backend/pull/1019) - 0.53.0 [`#1024`](https://github.com/isomerpages/isomercms-backend/pull/1024) -- fix(mediafileservice): disable sneky cloudmersive [`#1025`](https://github.com/isomerpages/isomercms-backend/pull/1025) - release(0.52.0): merge to prod [`#1013`](https://github.com/isomerpages/isomercms-backend/pull/1013) - Release/0.51.0 [`#1002`](https://github.com/isomerpages/isomercms-backend/pull/1002) - * refactor(formsg-site-clone): remove and add to site creation (#971) [`#992`](https://github.com/isomerpages/isomercms-backend/pull/992) @@ -87,6 +94,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 9 November 2023 +- fix(mediafileservice): disable sneky cloudmersive [`#1025`](https://github.com/isomerpages/isomercms-backend/pull/1025) - fix(file ext): fix casing + better logging [`#1020`](https://github.com/isomerpages/isomercms-backend/pull/1020) - fix(rr): capture file extensions that are in uppercase [`#1016`](https://github.com/isomerpages/isomercms-backend/pull/1016) - release(0.52.0): merge to develop [`#1012`](https://github.com/isomerpages/isomercms-backend/pull/1012) diff --git a/package-lock.json b/package-lock.json index 3756f65d9..7de7e5b90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "isomercms", - "version": "0.54.0", + "version": "0.55.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "isomercms", - "version": "0.54.0", + "version": "0.55.0", "dependencies": { "@aws-sdk/client-amplify": "^3.370.0", "@aws-sdk/client-cloudwatch-logs": "^3.370.0", diff --git a/package.json b/package.json index 9cf8c1266..e65f2e46e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "isomercms", - "version": "0.54.0", + "version": "0.55.0", "private": true, "scripts": { "build": "tsc -p tsconfig.build.json",