Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/0.55.0 #1038

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ 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)
- fix(cm): extra timeout [`#1027`](https://github.com/isomerpages/isomercms-backend/pull/1027)
- 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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion kishore-test-dev-emil/kishore-test-dev-emil
Submodule kishore-test-dev-emil deleted from 3478fc
1 change: 0 additions & 1 deletion pa-corp/pa-corp
Submodule pa-corp deleted from 1c144c
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isomercms",
"version": "0.54.0",
"version": "0.55.0",
"private": true,
"scripts": {
"build": "tsc -p tsconfig.build.json",
Expand Down
62 changes: 50 additions & 12 deletions src/services/identity/DeploymentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
ListJobsCommand,
ListJobsCommandOutput,
JobSummary,
StartJobCommand,
StartJobCommandOutput,
StartJobCommandInput,
} from "@aws-sdk/client-amplify"
import { ResultAsync, errAsync, fromPromise, okAsync } from "neverthrow"

Expand Down Expand Up @@ -77,19 +80,54 @@ class DeploymentClient {
this.amplifyClient.send(new ListJobsCommand({ appId, branchName }))
) as ResultAsync<ListJobsCommandOutput, AmplifyError>

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,
Expand Down
35 changes: 29 additions & 6 deletions src/services/identity/DeploymentsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down Expand Up @@ -98,15 +98,17 @@ class DeploymentsService {
createAmplifyAppOnAws = async (
repoName: string,
appName: string,
createStagingLite: boolean
isStagingLite: boolean
): Promise<Result<AmplifyInfo, AmplifyError>> => {
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)
Expand Down Expand Up @@ -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)
)
})
Expand Down
Loading