@codedrifters/configulator 0.0.424 → 0.0.426
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.mts +240 -2
- package/lib/index.d.ts +241 -3
- package/lib/index.js +389 -28
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +385 -31
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -41929,9 +41929,46 @@ import { merge as merge4 } from "ts-deepmerge";
|
|
|
41929
41929
|
var import_utils11 = __toESM(require_lib());
|
|
41930
41930
|
import { Component as Component22 } from "projen";
|
|
41931
41931
|
import { BuildWorkflow } from "projen/lib/build";
|
|
41932
|
-
import { GitHub as GitHub5, WorkflowSteps as WorkflowSteps2 } from "projen/lib/github";
|
|
41932
|
+
import { GitHub as GitHub5, GithubWorkflow, WorkflowSteps as WorkflowSteps2 } from "projen/lib/github";
|
|
41933
41933
|
import { JobPermission as JobPermission5 } from "projen/lib/github/workflows-model";
|
|
41934
41934
|
|
|
41935
|
+
// src/workflows/deploy-gate.ts
|
|
41936
|
+
var DEPLOY_GATE = {
|
|
41937
|
+
/**
|
|
41938
|
+
* Hold each deploy job behind a GitHub environment so its protection rules —
|
|
41939
|
+
* required reviewers, wait timers, deployment branch policies — apply before
|
|
41940
|
+
* the job is sent to a runner.
|
|
41941
|
+
*/
|
|
41942
|
+
ENVIRONMENT: "environment",
|
|
41943
|
+
/**
|
|
41944
|
+
* Split the workflow in two. A **plan** workflow builds and diffs but never
|
|
41945
|
+
* deploys; a dispatch-only **apply** workflow deploys the exact cloud
|
|
41946
|
+
* assembly a nominated plan run produced.
|
|
41947
|
+
*
|
|
41948
|
+
* Needs no protection rule, so unlike {@link DEPLOY_GATE.ENVIRONMENT} it
|
|
41949
|
+
* works on every GitHub plan. `environmentName` is optional here and layers
|
|
41950
|
+
* an environment onto the apply jobs.
|
|
41951
|
+
*/
|
|
41952
|
+
PLAN_APPLY: "plan-apply"
|
|
41953
|
+
};
|
|
41954
|
+
var resolveEnvironmentGate = (gate, environmentName, componentName) => {
|
|
41955
|
+
const trimmed = environmentName?.trim();
|
|
41956
|
+
if (gate === void 0) {
|
|
41957
|
+
if (trimmed) {
|
|
41958
|
+
throw new Error(
|
|
41959
|
+
`${componentName} requires \`gate\` to be set when \`environmentName\` is supplied, got "${environmentName}" with no gate`
|
|
41960
|
+
);
|
|
41961
|
+
}
|
|
41962
|
+
return void 0;
|
|
41963
|
+
}
|
|
41964
|
+
if (gate === DEPLOY_GATE.ENVIRONMENT && !trimmed) {
|
|
41965
|
+
throw new Error(
|
|
41966
|
+
`${componentName} requires a non-empty \`environmentName\` when \`gate\` is "${gate}"`
|
|
41967
|
+
);
|
|
41968
|
+
}
|
|
41969
|
+
return trimmed;
|
|
41970
|
+
};
|
|
41971
|
+
|
|
41935
41972
|
// src/workflows/home-repository.ts
|
|
41936
41973
|
var HOME_REPOSITORY_PATTERN = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;
|
|
41937
41974
|
var renderHomeRepositoryCondition = (homeRepository, componentName) => {
|
|
@@ -41946,6 +41983,105 @@ var renderHomeRepositoryCondition = (homeRepository, componentName) => {
|
|
|
41946
41983
|
return `github.repository == '${homeRepository}'`;
|
|
41947
41984
|
};
|
|
41948
41985
|
|
|
41986
|
+
// src/workflows/plan-apply.ts
|
|
41987
|
+
var VALIDATE_PLAN_JOB_ID = "validate-plan";
|
|
41988
|
+
var PLAN_RUN_ID_INPUT = "plan_run_id";
|
|
41989
|
+
var BUILD_ARTIFACT_NAME = "build-artifact";
|
|
41990
|
+
var PERMISSION_BACKUP_FILE = "permissions-backup.acl";
|
|
41991
|
+
var renderPlanValidationScript = (options) => {
|
|
41992
|
+
const {
|
|
41993
|
+
planWorkflowPath,
|
|
41994
|
+
allowedBranches,
|
|
41995
|
+
requireCurrentHead,
|
|
41996
|
+
verifyArtifactDigest
|
|
41997
|
+
} = options;
|
|
41998
|
+
return [
|
|
41999
|
+
"const raw = (process.env.PLAN_RUN_ID ?? '').trim();",
|
|
42000
|
+
"const runId = Number(raw);",
|
|
42001
|
+
"if (!/^[0-9]+$/.test(raw) || !Number.isSafeInteger(runId) || runId <= 0) {",
|
|
42002
|
+
' core.setFailed(`plan_run_id must be a positive run id, got "${raw}"`);',
|
|
42003
|
+
" return;",
|
|
42004
|
+
"}",
|
|
42005
|
+
"",
|
|
42006
|
+
"const { owner, repo } = context.repo;",
|
|
42007
|
+
"const { data: run } = await github.rest.actions.getWorkflowRun({",
|
|
42008
|
+
" owner,",
|
|
42009
|
+
" repo,",
|
|
42010
|
+
" run_id: runId,",
|
|
42011
|
+
"});",
|
|
42012
|
+
"",
|
|
42013
|
+
`const expectedPath = ${JSON.stringify(planWorkflowPath)};`,
|
|
42014
|
+
"if (run.path !== expectedPath) {",
|
|
42015
|
+
' core.setFailed(`Run ${runId} belongs to workflow "${run.path}", expected "${expectedPath}".`);',
|
|
42016
|
+
" return;",
|
|
42017
|
+
"}",
|
|
42018
|
+
"",
|
|
42019
|
+
'if (run.status !== "completed" || run.conclusion !== "success") {',
|
|
42020
|
+
' core.setFailed(`Run ${runId} is status "${run.status}" / conclusion "${run.conclusion}", expected a completed successful plan run.`);',
|
|
42021
|
+
" return;",
|
|
42022
|
+
"}",
|
|
42023
|
+
"",
|
|
42024
|
+
`const allowedBranches = ${JSON.stringify(allowedBranches)};`,
|
|
42025
|
+
'const branch = run.head_branch ?? "";',
|
|
42026
|
+
"const branchAllowed = allowedBranches.some((pattern) =>",
|
|
42027
|
+
' pattern.includes("*")',
|
|
42028
|
+
' ? branch.startsWith(pattern.slice(0, pattern.indexOf("*")))',
|
|
42029
|
+
" : branch === pattern,",
|
|
42030
|
+
");",
|
|
42031
|
+
"if (!branchAllowed) {",
|
|
42032
|
+
' core.setFailed(`Run ${runId} ran on branch "${branch}", which no deployment target in this workflow accepts (allowed: ${allowedBranches.join(", ")}).`);',
|
|
42033
|
+
" return;",
|
|
42034
|
+
"}",
|
|
42035
|
+
...requireCurrentHead ? [
|
|
42036
|
+
"",
|
|
42037
|
+
"const { data: liveBranch } = await github.rest.repos.getBranch({",
|
|
42038
|
+
" owner,",
|
|
42039
|
+
" repo,",
|
|
42040
|
+
" branch,",
|
|
42041
|
+
"});",
|
|
42042
|
+
"if (liveBranch.commit.sha !== run.head_sha) {",
|
|
42043
|
+
' core.setFailed(`Run ${runId} planned ${run.head_sha} but "${branch}" now points at ${liveBranch.commit.sha}. Re-run the plan workflow against the current head.`);',
|
|
42044
|
+
" return;",
|
|
42045
|
+
"}"
|
|
42046
|
+
] : [],
|
|
42047
|
+
"",
|
|
42048
|
+
"const artifacts = await github.paginate(",
|
|
42049
|
+
" github.rest.actions.listWorkflowRunArtifacts,",
|
|
42050
|
+
" { owner, repo, run_id: runId, per_page: 100 },",
|
|
42051
|
+
");",
|
|
42052
|
+
`const artifactName = ${JSON.stringify(BUILD_ARTIFACT_NAME)};`,
|
|
42053
|
+
"const artifact = artifacts.find((a) => a.name === artifactName);",
|
|
42054
|
+
"if (!artifact) {",
|
|
42055
|
+
' core.setFailed(`Run ${runId} published no "${artifactName}" artifact. Only a plan run whose build job completed can be applied.`);',
|
|
42056
|
+
" return;",
|
|
42057
|
+
"}",
|
|
42058
|
+
"if (artifact.expired) {",
|
|
42059
|
+
' core.setFailed(`The "${artifactName}" artifact on run ${runId} expired at ${artifact.expires_at}. Artifact retention is this gate\'s approval window \u2014 re-run the plan workflow.`);',
|
|
42060
|
+
" return;",
|
|
42061
|
+
"}",
|
|
42062
|
+
...verifyArtifactDigest ? [
|
|
42063
|
+
"if (!artifact.digest) {",
|
|
42064
|
+
' core.setFailed(`The "${artifactName}" artifact on run ${runId} reports no digest, so it cannot be verified. Disable planApply.verifyArtifactDigest or re-run the plan workflow.`);',
|
|
42065
|
+
" return;",
|
|
42066
|
+
"}",
|
|
42067
|
+
'core.setOutput("artifact_digest", artifact.digest);'
|
|
42068
|
+
] : [],
|
|
42069
|
+
"",
|
|
42070
|
+
'core.setOutput("head_sha", run.head_sha);',
|
|
42071
|
+
'core.setOutput("head_branch", branch);',
|
|
42072
|
+
"await core.summary",
|
|
42073
|
+
" .addHeading(`Applying plan run ${runId}`, 2)",
|
|
42074
|
+
" .addTable([",
|
|
42075
|
+
' [{ data: "Field", header: true }, { data: "Value", header: true }],',
|
|
42076
|
+
' ["Plan run", `<a href="${run.html_url}">${runId}</a>`],',
|
|
42077
|
+
' ["Branch", branch],',
|
|
42078
|
+
' ["Commit", run.head_sha],',
|
|
42079
|
+
' ["Artifact expires", artifact.expires_at ?? "unknown"],',
|
|
42080
|
+
" ])",
|
|
42081
|
+
" .write();"
|
|
42082
|
+
].join("\n");
|
|
42083
|
+
};
|
|
42084
|
+
|
|
41949
42085
|
// src/workflows/aws-deploy-workflow.ts
|
|
41950
42086
|
var PROD_DEPLOY_NAME = "prod-deploy";
|
|
41951
42087
|
var DIFF_OUTPUT_FILE = "cdk-diff.txt";
|
|
@@ -42017,6 +42153,20 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42017
42153
|
target.region
|
|
42018
42154
|
].join("-");
|
|
42019
42155
|
};
|
|
42156
|
+
/**
|
|
42157
|
+
* Build the deterministic GitHub Actions job name for a target's apply job.
|
|
42158
|
+
* Mirrors {@link buildJobName} with an `apply` verb.
|
|
42159
|
+
*/
|
|
42160
|
+
this.buildApplyJobName = (target) => {
|
|
42161
|
+
return [
|
|
42162
|
+
target.awsStageType,
|
|
42163
|
+
target.deploymentTargetRole,
|
|
42164
|
+
"apply",
|
|
42165
|
+
target.project.name,
|
|
42166
|
+
target.account,
|
|
42167
|
+
target.region
|
|
42168
|
+
].join("-");
|
|
42169
|
+
};
|
|
42020
42170
|
/**
|
|
42021
42171
|
* Build the CI artifact name for a target's captured diff.
|
|
42022
42172
|
*
|
|
@@ -42035,6 +42185,163 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42035
42185
|
target.region
|
|
42036
42186
|
].join("-");
|
|
42037
42187
|
};
|
|
42188
|
+
/**
|
|
42189
|
+
* Create the dispatch-only apply workflow and its validation job.
|
|
42190
|
+
*
|
|
42191
|
+
* The workflow file name defaults to the plan workflow's name suffixed with
|
|
42192
|
+
* `-apply`. A name already in use throws rather than silently colliding on
|
|
42193
|
+
* the underlying `.github/workflows/<name>.yml` file — the usual cause is two
|
|
42194
|
+
* `AwsDeployWorkflow`s sharing one build workflow, and the fix is an explicit
|
|
42195
|
+
* `planApply.applyWorkflowName`.
|
|
42196
|
+
*/
|
|
42197
|
+
this.createApplyWorkflow = (github, homeRepositoryCondition) => {
|
|
42198
|
+
const { applyWorkflowName, requireCurrentHead, verifyArtifactDigest } = this.planApplyOptions;
|
|
42199
|
+
if (github.tryFindWorkflow(applyWorkflowName)) {
|
|
42200
|
+
throw new Error(
|
|
42201
|
+
`AwsDeployWorkflow cannot create the apply workflow "${applyWorkflowName}" because a workflow with that name already exists. Set \`planApply.applyWorkflowName\` to something unique.`
|
|
42202
|
+
);
|
|
42203
|
+
}
|
|
42204
|
+
const workflow = new GithubWorkflow(github, applyWorkflowName);
|
|
42205
|
+
workflow.on({
|
|
42206
|
+
workflowDispatch: {
|
|
42207
|
+
inputs: {
|
|
42208
|
+
[PLAN_RUN_ID_INPUT]: {
|
|
42209
|
+
description: "Run id of the plan workflow run to apply. Its build artifact is deployed verbatim.",
|
|
42210
|
+
required: true,
|
|
42211
|
+
type: "string"
|
|
42212
|
+
}
|
|
42213
|
+
}
|
|
42214
|
+
}
|
|
42215
|
+
});
|
|
42216
|
+
const allowedBranches = Array.from(
|
|
42217
|
+
new Set(
|
|
42218
|
+
this.awsDeploymentTargets.flatMap(
|
|
42219
|
+
(target) => target.branches.map((b) => b.branch)
|
|
42220
|
+
)
|
|
42221
|
+
)
|
|
42222
|
+
);
|
|
42223
|
+
workflow.addJob(VALIDATE_PLAN_JOB_ID, {
|
|
42224
|
+
name: "Validate plan run",
|
|
42225
|
+
runsOn: ["ubuntu-latest"],
|
|
42226
|
+
permissions: {
|
|
42227
|
+
actions: JobPermission5.READ,
|
|
42228
|
+
contents: JobPermission5.READ
|
|
42229
|
+
},
|
|
42230
|
+
...homeRepositoryCondition ? { if: `\${{ ${homeRepositoryCondition} }}` } : {},
|
|
42231
|
+
outputs: {
|
|
42232
|
+
head_sha: { stepId: "validate_plan_run", outputName: "head_sha" },
|
|
42233
|
+
head_branch: { stepId: "validate_plan_run", outputName: "head_branch" },
|
|
42234
|
+
...verifyArtifactDigest ? {
|
|
42235
|
+
artifact_digest: {
|
|
42236
|
+
stepId: "validate_plan_run",
|
|
42237
|
+
outputName: "artifact_digest"
|
|
42238
|
+
}
|
|
42239
|
+
} : {}
|
|
42240
|
+
},
|
|
42241
|
+
steps: [
|
|
42242
|
+
{
|
|
42243
|
+
name: "Validate plan run",
|
|
42244
|
+
id: "validate_plan_run",
|
|
42245
|
+
uses: "actions/github-script@v9",
|
|
42246
|
+
/**
|
|
42247
|
+
* The dispatch input reaches the script through the environment
|
|
42248
|
+
* rather than a `${{ }}` interpolation, so a crafted run id cannot
|
|
42249
|
+
* inject JavaScript into the validation itself.
|
|
42250
|
+
*/
|
|
42251
|
+
env: {
|
|
42252
|
+
PLAN_RUN_ID: `\${{ inputs.${PLAN_RUN_ID_INPUT} }}`
|
|
42253
|
+
},
|
|
42254
|
+
with: {
|
|
42255
|
+
script: renderPlanValidationScript({
|
|
42256
|
+
planWorkflowPath: `.github/workflows/${this.buildWorkflow.name}.yml`,
|
|
42257
|
+
allowedBranches,
|
|
42258
|
+
requireCurrentHead,
|
|
42259
|
+
verifyArtifactDigest
|
|
42260
|
+
})
|
|
42261
|
+
}
|
|
42262
|
+
}
|
|
42263
|
+
]
|
|
42264
|
+
});
|
|
42265
|
+
return workflow;
|
|
42266
|
+
};
|
|
42267
|
+
/**
|
|
42268
|
+
* Register one target's apply job on the apply workflow.
|
|
42269
|
+
*
|
|
42270
|
+
* Differences from the `single`-gate deploy job, all of them forced by the
|
|
42271
|
+
* apply run having no build job of its own:
|
|
42272
|
+
*
|
|
42273
|
+
* - `needs` starts at the validation job rather than `build`, so a plan run
|
|
42274
|
+
* that fails any check skips every apply job instead of deploying.
|
|
42275
|
+
* - `actions: read` is added, which is what lets `actions/download-artifact`
|
|
42276
|
+
* reach across runs.
|
|
42277
|
+
* - No `pull-requests: write`, and no sticky PR comment step: an apply is
|
|
42278
|
+
* always a `workflow_dispatch`, so the comment could never fire.
|
|
42279
|
+
* - No branch filter on `github.ref`. The ref an operator happens to
|
|
42280
|
+
* dispatch from is unrelated to what was planned; the branch that matters
|
|
42281
|
+
* is the plan run's, and the validation job checks that one.
|
|
42282
|
+
*
|
|
42283
|
+
* When `environmentName` is also supplied, it lands here rather than on the
|
|
42284
|
+
* plan's jobs — a second approver on top of whoever dispatched the apply.
|
|
42285
|
+
* `validate-plan` stays ungated so its verdict is available to read *before*
|
|
42286
|
+
* the approval is given.
|
|
42287
|
+
*/
|
|
42288
|
+
this.addApplyJob = (workflow, target, homeRepositoryCondition) => {
|
|
42289
|
+
const applyJobName = this.buildApplyJobName(target);
|
|
42290
|
+
const { verifyArtifactDigest } = this.planApplyOptions;
|
|
42291
|
+
const artifactsDirectory = this.rootProject.artifactsDirectory;
|
|
42292
|
+
workflow.addJob(applyJobName, {
|
|
42293
|
+
name: `Apply ${this.project.name} ${target.awsStageType}/${target.deploymentTargetRole}/${target.account}/${target.region}`,
|
|
42294
|
+
needs: [
|
|
42295
|
+
VALIDATE_PLAN_JOB_ID,
|
|
42296
|
+
...this.deployAfterTargets.map((p) => this.buildApplyJobName(p))
|
|
42297
|
+
],
|
|
42298
|
+
runsOn: ["ubuntu-latest"],
|
|
42299
|
+
permissions: {
|
|
42300
|
+
actions: JobPermission5.READ,
|
|
42301
|
+
contents: JobPermission5.READ,
|
|
42302
|
+
idToken: JobPermission5.WRITE
|
|
42303
|
+
},
|
|
42304
|
+
...this.environmentName ? { environment: this.environmentName } : void 0,
|
|
42305
|
+
/**
|
|
42306
|
+
* Shares the deploy job's group name so an apply can never overlap a
|
|
42307
|
+
* same-target deploy. `cancel-in-progress` is spelled out rather than
|
|
42308
|
+
* left to GitHub's default: cancelling a half-finished `cdk deploy`
|
|
42309
|
+
* strands a CloudFormation stack mid-update.
|
|
42310
|
+
*/
|
|
42311
|
+
concurrency: {
|
|
42312
|
+
group: this.buildJobName(target),
|
|
42313
|
+
"cancel-in-progress": false
|
|
42314
|
+
},
|
|
42315
|
+
...homeRepositoryCondition ? { if: `\${{ ${homeRepositoryCondition} }}` } : {},
|
|
42316
|
+
steps: [
|
|
42317
|
+
/**
|
|
42318
|
+
* Cross-run download of the plan's assembly. `run-id` plus an explicit
|
|
42319
|
+
* `github-token` is what makes `actions/download-artifact` look outside
|
|
42320
|
+
* the current run; without both it silently searches this run and finds
|
|
42321
|
+
* nothing.
|
|
42322
|
+
*/
|
|
42323
|
+
{
|
|
42324
|
+
name: "Download plan build artifacts",
|
|
42325
|
+
uses: "actions/download-artifact@v8",
|
|
42326
|
+
with: {
|
|
42327
|
+
name: BUILD_ARTIFACT_NAME,
|
|
42328
|
+
path: artifactsDirectory,
|
|
42329
|
+
"run-id": `\${{ inputs.${PLAN_RUN_ID_INPUT} }}`,
|
|
42330
|
+
"github-token": "${{ secrets.GITHUB_TOKEN }}",
|
|
42331
|
+
...verifyArtifactDigest ? {
|
|
42332
|
+
"artifact-digest": `\${{ needs.${VALIDATE_PLAN_JOB_ID}.outputs.artifact_digest }}`
|
|
42333
|
+
} : {}
|
|
42334
|
+
}
|
|
42335
|
+
},
|
|
42336
|
+
{
|
|
42337
|
+
name: "Restore build artifact permissions",
|
|
42338
|
+
continueOnError: true,
|
|
42339
|
+
run: `cd ${artifactsDirectory} && setfacl --restore=${PERMISSION_BACKUP_FILE}`
|
|
42340
|
+
},
|
|
42341
|
+
...this.deploySteps(target, { stickyPrComment: false })
|
|
42342
|
+
]
|
|
42343
|
+
});
|
|
42344
|
+
};
|
|
42038
42345
|
/**
|
|
42039
42346
|
* Builds a GitHub Actions condition string that checks if the current branch
|
|
42040
42347
|
* matches any of the provided branch patterns.
|
|
@@ -42063,7 +42370,15 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42063
42370
|
}
|
|
42064
42371
|
return conditions.join(" || ");
|
|
42065
42372
|
};
|
|
42066
|
-
|
|
42373
|
+
/**
|
|
42374
|
+
* Steps for a target's deploy job.
|
|
42375
|
+
*
|
|
42376
|
+
* `stickyPrComment` drops the sticky-PR-comment step when false. Apply jobs
|
|
42377
|
+
* pass false: they only ever run on `workflow_dispatch` and so could never
|
|
42378
|
+
* satisfy that step's own `pull_request` guard.
|
|
42379
|
+
*/
|
|
42380
|
+
this.deploySteps = (target, options = {}) => {
|
|
42381
|
+
const { stickyPrComment = true } = options;
|
|
42067
42382
|
const {
|
|
42068
42383
|
awsStageType,
|
|
42069
42384
|
deploymentTargetRole,
|
|
@@ -42142,15 +42457,17 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42142
42457
|
* comment is keyed by the deploy job name so dev/stage/prod comments
|
|
42143
42458
|
* don't collide on the same PR.
|
|
42144
42459
|
*/
|
|
42145
|
-
|
|
42146
|
-
|
|
42147
|
-
|
|
42148
|
-
|
|
42149
|
-
|
|
42150
|
-
|
|
42151
|
-
|
|
42460
|
+
...stickyPrComment ? [
|
|
42461
|
+
{
|
|
42462
|
+
name: "Sticky PR comment with deploy endpoints",
|
|
42463
|
+
if: "github.event_name == 'pull_request' && hashFiles('deploy-urls.md') != ''",
|
|
42464
|
+
uses: "marocchino/sticky-pull-request-comment@v3",
|
|
42465
|
+
with: {
|
|
42466
|
+
header: deployJobName,
|
|
42467
|
+
path: "deploy-urls.md"
|
|
42468
|
+
}
|
|
42152
42469
|
}
|
|
42153
|
-
|
|
42470
|
+
] : []
|
|
42154
42471
|
];
|
|
42155
42472
|
};
|
|
42156
42473
|
/**
|
|
@@ -42294,11 +42611,23 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42294
42611
|
(target) => target.awsStageType === this.awsStageType && target.ciDeployment
|
|
42295
42612
|
) ?? [];
|
|
42296
42613
|
this.deployAfterTargets = options.deployAfterTargets ?? [];
|
|
42614
|
+
this.gate = options.gate;
|
|
42615
|
+
const isPlanApply = this.gate === DEPLOY_GATE.PLAN_APPLY;
|
|
42616
|
+
if (isPlanApply && options.diff?.enabled === false) {
|
|
42617
|
+
throw new Error(
|
|
42618
|
+
"AwsDeployWorkflow cannot disable `diff` under the `plan-apply` gate: the diff jobs are what keep the plan workflow publishing the build artifact the apply workflow deploys."
|
|
42619
|
+
);
|
|
42620
|
+
}
|
|
42297
42621
|
this.diffOptions = {
|
|
42298
|
-
enabled: options.diff?.enabled ??
|
|
42622
|
+
enabled: options.diff?.enabled ?? isPlanApply,
|
|
42299
42623
|
artifact: options.diff?.artifact ?? true,
|
|
42300
42624
|
summary: options.diff?.summary ?? true
|
|
42301
42625
|
};
|
|
42626
|
+
this.environmentName = resolveEnvironmentGate(
|
|
42627
|
+
options.gate,
|
|
42628
|
+
options.environmentName,
|
|
42629
|
+
"AwsDeployWorkflow"
|
|
42630
|
+
);
|
|
42302
42631
|
this.homeRepository = options.homeRepository;
|
|
42303
42632
|
const homeRepositoryCondition = renderHomeRepositoryCondition(
|
|
42304
42633
|
this.homeRepository,
|
|
@@ -42376,6 +42705,17 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42376
42705
|
...buildWorkflowOptions?.preBuildSteps ?? []
|
|
42377
42706
|
]
|
|
42378
42707
|
});
|
|
42708
|
+
this.planApplyOptions = {
|
|
42709
|
+
applyWorkflowName: options.planApply?.applyWorkflowName ?? `${this.buildWorkflow.name}-apply`,
|
|
42710
|
+
requireCurrentHead: options.planApply?.requireCurrentHead ?? false,
|
|
42711
|
+
verifyArtifactDigest: options.planApply?.verifyArtifactDigest ?? false
|
|
42712
|
+
};
|
|
42713
|
+
if (isPlanApply) {
|
|
42714
|
+
this.applyWorkflow = this.createApplyWorkflow(
|
|
42715
|
+
github,
|
|
42716
|
+
homeRepositoryCondition
|
|
42717
|
+
);
|
|
42718
|
+
}
|
|
42379
42719
|
this.awsDeploymentTargets.forEach((target) => {
|
|
42380
42720
|
const deployJobName = this.buildJobName(target);
|
|
42381
42721
|
const branchFilterCondition = this.buildBranchFilterCondition(
|
|
@@ -42386,24 +42726,31 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42386
42726
|
...homeRepositoryCondition ? [homeRepositoryCondition] : [],
|
|
42387
42727
|
...branchFilterCondition ? [`(${branchFilterCondition})`] : []
|
|
42388
42728
|
].join(" && ") + " }}";
|
|
42389
|
-
this.
|
|
42390
|
-
|
|
42391
|
-
|
|
42392
|
-
|
|
42393
|
-
|
|
42394
|
-
|
|
42395
|
-
|
|
42396
|
-
|
|
42397
|
-
|
|
42398
|
-
|
|
42399
|
-
|
|
42400
|
-
|
|
42401
|
-
|
|
42402
|
-
|
|
42403
|
-
|
|
42404
|
-
|
|
42405
|
-
|
|
42406
|
-
|
|
42729
|
+
if (this.applyWorkflow) {
|
|
42730
|
+
this.addApplyJob(this.applyWorkflow, target, homeRepositoryCondition);
|
|
42731
|
+
} else {
|
|
42732
|
+
const gatedOnDiff = !!this.environmentName && this.diffOptions.enabled;
|
|
42733
|
+
this.buildWorkflow.addPostBuildJob(deployJobName, {
|
|
42734
|
+
name: `Deploy ${this.project.name} ${target.awsStageType}/${target.deploymentTargetRole}/${target.account}/${target.region}`,
|
|
42735
|
+
needs: [
|
|
42736
|
+
"build",
|
|
42737
|
+
...gatedOnDiff ? [this.buildDiffJobName(target)] : [],
|
|
42738
|
+
...this.deployAfterTargets.map((p) => {
|
|
42739
|
+
return this.buildJobName(p);
|
|
42740
|
+
})
|
|
42741
|
+
],
|
|
42742
|
+
runsOn: ["ubuntu-latest"],
|
|
42743
|
+
permissions: {
|
|
42744
|
+
contents: JobPermission5.READ,
|
|
42745
|
+
idToken: JobPermission5.WRITE,
|
|
42746
|
+
pullRequests: JobPermission5.WRITE
|
|
42747
|
+
},
|
|
42748
|
+
...this.environmentName ? { environment: this.environmentName } : void 0,
|
|
42749
|
+
concurrency: deployJobName,
|
|
42750
|
+
if: jobCondition,
|
|
42751
|
+
steps: [...this.deploySteps(target)]
|
|
42752
|
+
});
|
|
42753
|
+
}
|
|
42407
42754
|
if (this.diffOptions.enabled) {
|
|
42408
42755
|
const diffJobName = this.buildDiffJobName(target);
|
|
42409
42756
|
this.buildWorkflow.addPostBuildJob(diffJobName, {
|
|
@@ -42449,7 +42796,7 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component22 {
|
|
|
42449
42796
|
|
|
42450
42797
|
// src/workflows/aws-teardown-workflow.ts
|
|
42451
42798
|
import { Component as Component23 } from "projen";
|
|
42452
|
-
import { GitHub as GitHub6, GithubWorkflow } from "projen/lib/github";
|
|
42799
|
+
import { GitHub as GitHub6, GithubWorkflow as GithubWorkflow2 } from "projen/lib/github";
|
|
42453
42800
|
import { JobPermission as JobPermission6 } from "projen/lib/github/workflows-model";
|
|
42454
42801
|
var DEFAULT_TEARDOWN_BRANCH_PATTERNS = [
|
|
42455
42802
|
"feat/*",
|
|
@@ -42514,7 +42861,7 @@ var AwsTeardownWorkflow = class extends Component23 {
|
|
|
42514
42861
|
homeRepository,
|
|
42515
42862
|
"AwsTeardownWorkflow"
|
|
42516
42863
|
);
|
|
42517
|
-
const workflow = new
|
|
42864
|
+
const workflow = new GithubWorkflow2(github, "teardown-dev");
|
|
42518
42865
|
workflow.on({
|
|
42519
42866
|
workflowDispatch: {},
|
|
42520
42867
|
schedule: [
|
|
@@ -43312,6 +43659,7 @@ export {
|
|
|
43312
43659
|
AwsDeploymentConfig,
|
|
43313
43660
|
AwsDeploymentTarget,
|
|
43314
43661
|
AwsTeardownWorkflow,
|
|
43662
|
+
BUILD_ARTIFACT_NAME,
|
|
43315
43663
|
BUILT_IN_BUNDLES,
|
|
43316
43664
|
BUNDLE_OWNERSHIP,
|
|
43317
43665
|
CDK_BOOTSTRAP_DEFAULTS_BY_STAGE,
|
|
@@ -43394,6 +43742,7 @@ export {
|
|
|
43394
43742
|
DEFAULT_UNBLOCK_COMMENT_TEMPLATE,
|
|
43395
43743
|
DEFAULT_UNBLOCK_DEPENDENTS_ENABLED,
|
|
43396
43744
|
DEFAULT_UPSTREAM_CONFIGULATOR_ENABLED,
|
|
43745
|
+
DEPLOY_GATE,
|
|
43397
43746
|
DOCS_SYNC_AUDIT_SCHEMA_VERSION,
|
|
43398
43747
|
GITHUB_ISSUE_TYPES,
|
|
43399
43748
|
GITHUB_ISSUE_TYPE_BY_TITLE_PREFIX,
|
|
@@ -43409,7 +43758,9 @@ export {
|
|
|
43409
43758
|
MONOREPO_LAYOUT,
|
|
43410
43759
|
MonorepoProject,
|
|
43411
43760
|
Nvmrc,
|
|
43761
|
+
PERMISSION_BACKUP_FILE,
|
|
43412
43762
|
PHASE_LABEL_TYPE_MAP,
|
|
43763
|
+
PLAN_RUN_ID_INPUT,
|
|
43413
43764
|
PROD_DEPLOY_NAME,
|
|
43414
43765
|
PROGRESS_FILES_FORMAT_VALUES,
|
|
43415
43766
|
PnpmWorkspace,
|
|
@@ -43443,6 +43794,7 @@ export {
|
|
|
43443
43794
|
TypeScriptConfig,
|
|
43444
43795
|
TypeScriptProject,
|
|
43445
43796
|
UNKNOWN_TYPE_FALLBACK_TIER,
|
|
43797
|
+
VALIDATE_PLAN_JOB_ID,
|
|
43446
43798
|
VALID_PRIORITY_VALUES,
|
|
43447
43799
|
VALID_STATUS_VALUES,
|
|
43448
43800
|
VERSION,
|
|
@@ -43587,6 +43939,7 @@ export {
|
|
|
43587
43939
|
renderNextRequirementIdProcedure,
|
|
43588
43940
|
renderPhaseTypeInvariantSection,
|
|
43589
43941
|
renderPhaseTypeInvariantShellHelpers,
|
|
43942
|
+
renderPlanValidationScript,
|
|
43590
43943
|
renderPriorityRulesSection,
|
|
43591
43944
|
renderProgressFileName,
|
|
43592
43945
|
renderProgressFilePath,
|
|
@@ -43624,6 +43977,7 @@ export {
|
|
|
43624
43977
|
resolveBuildPolicy,
|
|
43625
43978
|
resolveBundleAgentTiers,
|
|
43626
43979
|
resolveDefaultAgentTier,
|
|
43980
|
+
resolveEnvironmentGate,
|
|
43627
43981
|
resolveIssueDefaults,
|
|
43628
43982
|
resolveIssueTemplates,
|
|
43629
43983
|
resolveModelAlias,
|