cdklabs / cdk-pipelines-github

Apache License 2.0
348 stars 37 forks source link

allow for escape hatching #293

Closed kaizencc closed 2 years ago

kaizencc commented 2 years ago

This library is modeled after CDK Pipelines, and is meant to be feature complete compared to that library. There is one difference however -- CDK Pipelines is a CDK construct that is compiled down to a CloudFormation template, which allows for the escape-hatching mechanism that unlocks any and all out-of-bound changes to the underlying CloudFormation template. As of right now, CDK Pipelines GitHub does not have this feature (since it compiles to a GitHub Workflow) and is thus less customizable than its counterpart.

CDK Pipelines GitHub needs a way of escape hatching to the GitHub Workflow.

danieljamesscott commented 2 years ago

Could this be done by providing access to the workflow data structure somehow? https://github.com/cdklabs/cdk-pipelines-github/blob/main/src/pipeline.ts#L283

Possibly by passing a callback function or something into the pipeline, so that users can manipulate the workflow data after synthesis, but before writing?

kaizencc commented 2 years ago

I think the way to go about this will be similar to how projen supports escape hatching (since they also are modifying json and yaml files): https://github.com/projen/projen/blob/main/docs/escape-hatches.md

In my mind, this will look something like this:

const workflow = new GitHubWorkflow(...);

workflow.patch(YamlPatch.add('/steps/0/env/VAR', 'VAL'));

Hopefully I have the time to implement this in the coming weeks. +1s would help me prioritize this, and a contribution would certainly help here, but be prepared to add plenty of tests to make sure that the APIs we add correctly modify the yaml files in ways we expect (no snapshot tests :) ).