-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from Opetushallitus/EH-1764
EH-1764: Tekstiviestimuutokset
- Loading branch information
Showing
6 changed files
with
204 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,63 @@ | ||
#!/usr/bin/env node | ||
import { App } from 'aws-cdk-lib' | ||
import { App } from "aws-cdk-lib"; | ||
import { HeratepalveluAMISStack } from "../lib/amis"; | ||
import { HeratepalveluTEPStack } from "../lib/tep"; | ||
import { HeratepalveluTPKStack } from "../lib/tpk"; | ||
import { HeratepalveluTEPRAHOITUSStack } from "../lib/teprah"; | ||
import { simpleGit, SimpleGitOptions } from "simple-git"; | ||
|
||
const checkGitStatus = async () => { | ||
const options: Partial<SimpleGitOptions> = { | ||
baseDir: process.cwd(), | ||
binary: 'git', | ||
maxConcurrentProcesses: 6, | ||
trimmed: false, | ||
}; | ||
const git = simpleGit(options); | ||
|
||
const status = await git.status(); | ||
const gitLog = await git.log(); | ||
const upstreamBranch = await git.getRemotes(); | ||
|
||
if (upstreamBranch.length === 0) { | ||
throw new Error("No upstream branch"); | ||
} | ||
|
||
const git = require("git-utils"); | ||
const repo = git.open("."); | ||
|
||
const status = repo.getStatus(); | ||
const aheadBehindCount = repo.getAheadBehindCount(); | ||
const upstreamBranch = repo.getUpstreamBranch(); | ||
|
||
if (!upstreamBranch) { | ||
throw new Error("No upstream branch"); | ||
} | ||
|
||
const canDeploy = (Object.entries(status).length === 0 && aheadBehindCount.ahead === 0 && aheadBehindCount.behind === 0); | ||
|
||
const version = canDeploy ? repo.getReferenceTarget(repo.getHead()) : "uncommitted"; | ||
|
||
const app = new App(); | ||
|
||
new HeratepalveluAMISStack(app, "sieni-services-heratepalvelu", 'sieni', version); | ||
const tepSieni = new HeratepalveluTEPStack(app, "sieni-services-heratepalvelu-tep", 'sieni', version); | ||
new HeratepalveluTEPRAHOITUSStack(app, "sieni-services-heratepalvelu-teprah", 'sieni', version, tepSieni.jaksotunnusTable); | ||
new HeratepalveluTPKStack(app, "sieni-services-heratepalvelu-tpk", 'sieni', version, tepSieni.jaksotunnusTable); | ||
|
||
if (canDeploy) { | ||
new HeratepalveluAMISStack(app, "pallero-services-heratepalvelu", 'pallero', version); | ||
const tepPallero = new HeratepalveluTEPStack(app, "pallero-services-heratepalvelu-tep", 'pallero', version); | ||
new HeratepalveluTEPRAHOITUSStack(app, "pallero-services-heratepalvelu-teprah", 'pallero', version, tepPallero.jaksotunnusTable); | ||
new HeratepalveluTPKStack(app, "pallero-services-heratepalvelu-tpk", 'pallero', version, tepPallero.jaksotunnusTable); | ||
|
||
if (upstreamBranch === "refs/remotes/origin/master") { | ||
new HeratepalveluAMISStack(app, "sade-services-heratepalvelu", 'sade', version); | ||
const tepSade = new HeratepalveluTEPStack(app, "sade-services-heratepalvelu-tep", 'sade', version); | ||
new HeratepalveluTEPRAHOITUSStack(app, "sade-services-heratepalvelu-teprah", 'sade', version, tepSade.jaksotunnusTable); | ||
new HeratepalveluTPKStack(app, "sade-services-heratepalvelu-tpk", 'sade', version, tepSade.jaksotunnusTable); | ||
const version = status.isClean() ? gitLog.latest?.hash ?? "uncommitted" : "uncommitted"; | ||
|
||
const app = new App(); | ||
|
||
new HeratepalveluAMISStack(app, "sieni-services-heratepalvelu", 'sieni', version); | ||
const tepSieni = new HeratepalveluTEPStack(app, "sieni-services-heratepalvelu-tep", 'sieni', version); | ||
new HeratepalveluTEPRAHOITUSStack(app, "sieni-services-heratepalvelu-teprah", 'sieni', version, tepSieni.jaksotunnusTable); | ||
new HeratepalveluTPKStack(app, "sieni-services-heratepalvelu-tpk", 'sieni', version, tepSieni.jaksotunnusTable); | ||
|
||
if (status.isClean() && status.ahead === 0 && status.behind === 0) { | ||
new HeratepalveluAMISStack(app, "pallero-services-heratepalvelu", 'pallero', version); | ||
const tepPallero = new HeratepalveluTEPStack(app, "pallero-services-heratepalvelu-tep", 'pallero', version); | ||
new HeratepalveluTEPRAHOITUSStack(app, "pallero-services-heratepalvelu-teprah", 'pallero', version, tepPallero.jaksotunnusTable); | ||
new HeratepalveluTPKStack(app, "pallero-services-heratepalvelu-tpk", 'pallero', version, tepPallero.jaksotunnusTable); | ||
|
||
if (status.tracking === "origin/master") { | ||
new HeratepalveluAMISStack(app, "sade-services-heratepalvelu", 'sade', version); | ||
const tepSade = new HeratepalveluTEPStack(app, "sade-services-heratepalvelu-tep", 'sade', version); | ||
new HeratepalveluTEPRAHOITUSStack(app, "sade-services-heratepalvelu-teprah", 'sade', version, tepSade.jaksotunnusTable); | ||
new HeratepalveluTPKStack(app, "sade-services-heratepalvelu-tpk", 'sade', version, tepSade.jaksotunnusTable); | ||
} else { | ||
console.log("\nNOT IN MASTER BRANCH!!!\n") | ||
} | ||
} else { | ||
console.log("\nNOT IN MASTER BRANCH!!!\n") | ||
console.log("\nUncommited changes or local is ahead/behind of remote, so not doing anything:\n"); | ||
console.log(status); | ||
console.log("\n"); | ||
} | ||
} else { | ||
console.log("\nUncommited changes or local is ahead/behind of remote, so not doing anything:\n"); | ||
console.log(status); | ||
console.log(aheadBehindCount); | ||
console.log("\n"); | ||
} | ||
}; | ||
|
||
checkGitStatus() | ||
.then(() => { | ||
console.log("Done checking git status."); | ||
}) | ||
.catch((e) => { | ||
console.log("Error in git status check:", e); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.