You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Closely related is jobs.<job_id>.continue-on-error - which allows a job to act as if it succeeds even when it fails, making a job that cannot fail
1, 2, and 4 means that we only need the if statement on the build phase, and can skip if statements on publish steps. Depending on how 4 gets "fixed" either an if will need to be added with !(failure() || cancelled()) (As this workflow run demonstrates).
I see no value on adding (customized) if statements on publish jobs in the absence of a way to correlate the asset being deployed with some tangible asset name. Even then the value is dubious, since it'll likely invalidate the deployment since asset publish steps are shared by deployment steps that use those assets.
In a closely related issue, needs is used to handle dependencies, which the only way to make a stage NOT depend on another stage is with pipeline.addWave(), but that doesn't support GitHub options such as this if in the current code.
In the PR i have ready, this code works as expected (explained more below):
constpipeline=newGitHubWorkflow(app,'Pipeline',{workflowPath: `${dir}/.github/workflows/deploy.yml`,synth: newShellStep('Build',{installCommands: ['yarn'],commands: ['yarn build'],}),});conststageA=newGitHubStage(app,'MyStageA',{env: {account: '111111111111',region: 'us-east-1'},jobSettings: {if: "success() && contains(github.event.issue.labels.*.name, 'deployToA')",},});newStack(stageA,'MyStackA');conststageB=newGitHubStage(app,'MyStageB',{env: {account: '12345678901',region: 'us-east-1'},jobSettings: {if: "success() && contains(github.event.issue.labels.*.name, 'deployToB')",},});newStack(stageB,'MyStackB');// Make a wave to have the stages be parallel (not depend on each other)constwave=pipeline.addWave('MyWave');wave.addStage(stageA);wave.addStage(stageB);
This makes four jobs:
Build-Build - with if set
Assets-FileAsset1 - needs Build-Build but doesn't have if set otherwise
MyWave-MyStageA-MyStackA-Deploy - needs Build-Build and Assets-FileAsset1 and has the correct if set
MyWave-MyStageB-MyStackB-Deploy - also needs Build-Build and Assets-FileAsset1 and has the correct if set
If it were pipeline.addStage(stageA); and pipeline.addStage(stageB); then there would be an additional needs value of MyWave-MyStageA-MyStackA-Deploy
Obviously there's a new construct GitHubStage, and a new GitHubWorkflow.addWave(). We can discuss technical details in the PR about how these work and if we want to maintain those names, etc.
You can use the following status check functions as expressions in if conditionals. A default status check of success() is applied unless you include one of these functions.
This continues from the discussion in #365 with the
if
control.Looking at the docs for
jobs.<job_id>.if
, it appears that:if
statement, if present, can allow a step to build if dependent steps (injobs.<job_id>.needs
) fail, skip, or are cancelled.if
statement, if omitted, is the same asif: success()
1if
expression options that allow bypassing failure are: (Same reference.)always()
- ignores failure AND cancellationfailure()
- ONLY on failurecancelled()
- ONLY if the workflow was cancelledsuccess() || failure()
- unlikealways()
this allows cancellation of a stepif
skips dependent steps unless one of the above expressions is added, known issue: Job-level "if" condition not evaluated correctly if job in "needs" property is skipped actions/runner#491jobs.<job_id>.continue-on-error
- which allows a job to act as if it succeeds even when it fails, making a job that cannot fail1, 2, and 4 means that we only need the
if
statement on the build phase, and can skipif
statements on publish steps. Depending on how 4 gets "fixed" either anif
will need to be added with!(failure() || cancelled())
(As this workflow run demonstrates).I see no value on adding (customized)
if
statements on publish jobs in the absence of a way to correlate the asset being deployed with some tangible asset name. Even then the value is dubious, since it'll likely invalidate the deployment since asset publish steps are shared by deployment steps that use those assets.In a closely related issue,
needs
is used to handle dependencies, which the only way to make a stage NOT depend on another stage is withpipeline.addWave()
, but that doesn't support GitHub options such as thisif
in the current code.In the PR i have ready, this code works as expected (explained more below):
This makes four jobs:
Build-Build
- withif
setAssets-FileAsset1
- needsBuild-Build
but doesn't haveif
set otherwiseMyWave-MyStageA-MyStackA-Deploy
- needsBuild-Build
andAssets-FileAsset1
and has the correctif
setMyWave-MyStageB-MyStackB-Deploy
- also needsBuild-Build
andAssets-FileAsset1
and has the correctif
setpipeline.addStage(stageA);
andpipeline.addStage(stageB);
then there would be an additional needs value ofMyWave-MyStageA-MyStackA-Deploy
Obviously there's a new construct
GitHubStage
, and a newGitHubWorkflow.addWave()
. We can discuss technical details in the PR about how these work and if we want to maintain those names, etc.Footnotes
According to the docs here:
↩The text was updated successfully, but these errors were encountered: