<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Leo Lapworth Blog]]></title><description><![CDATA[Leo Lapworth Blog]]></description><link>https://blog.cuckoo.org</link><generator>RSS for Node</generator><lastBuildDate>Mon, 04 May 2026 17:10:46 GMT</lastBuildDate><atom:link href="https://blog.cuckoo.org/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[AWS Pipelines with Github Release trigger in CDK]]></title><description><![CDATA[Problem
CDK pipeline supports GitHub webhook, but on branch push events, not on release events.
UPDATE 2022
The after migrating to the modern CDK Pipeline API this approach no longer works.
Instead we have setup a GitHub action that is triggered on r...]]></description><link>https://blog.cuckoo.org/aws-pipelines-with-github-release-trigger-in-cdk</link><guid isPermaLink="true">https://blog.cuckoo.org/aws-pipelines-with-github-release-trigger-in-cdk</guid><category><![CDATA[aws-cdk]]></category><category><![CDATA[GitHub]]></category><dc:creator><![CDATA[Leo Lapworth]]></dc:creator><pubDate>Wed, 23 Jun 2021 06:20:51 GMT</pubDate><content:encoded><![CDATA[<h3 id="heading-problem">Problem</h3>
<p>CDK pipeline supports GitHub webhook, but on <code>branch push events</code>, not on <code>release events</code>.</p>
<h3 id="heading-update-2022">UPDATE 2022</h3>
<p>The after <a target="_blank" href="https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/pipelines/ORIGINAL_API.md">migrating to the modern CDK Pipeline API</a> this approach no longer works.</p>
<p>Instead we have setup a GitHub action that is triggered on <code>release</code> and pushes to a <code>release_to_production</code> branch and use the CDK Pipeline to trigger from the push event on that instead.</p>
<p>This ends up with a cleaner CDK setup even if relying on a branch rather than a release directly</p>
<h3 id="heading-solution">Solution...</h3>
<p>Disable triggers when you create a <code>GitHubSourceAction</code></p>
<pre><code class="lang-ts">   <span class="hljs-keyword">const</span> ghAction = <span class="hljs-keyword">new</span> codepipeline_actions.GitHubSourceAction({
      actionName: <span class="hljs-string">'GitHubRelease'</span>,
      ....
      trigger: codepipeline_actions.GitHubTrigger.NONE, <span class="hljs-comment">// we will add our own below</span>
    });

    <span class="hljs-comment">// Everything else</span>
    <span class="hljs-keyword">const</span> synthAction = pipelines.SimpleSynthAction.standardNpmSynth({
      sourceArtifact,
      cloudAssemblyArtifact,
      buildCommand: <span class="hljs-string">'echo "HELLO!"'</span>,
    });

    <span class="hljs-keyword">const</span> myPipeLine = <span class="hljs-keyword">new</span> pipelines.CdkPipeline(<span class="hljs-built_in">this</span>, <span class="hljs-string">'Pipeline'</span>, {
      pipelineName: <span class="hljs-string">'MyAppPipeline'</span>,
      cloudAssemblyArtifact,

      sourceAction: ghAction,
      synthAction,
    });
</code></pre>
<p>Create your own webhook and change the filters to look at <code>$.action</code> and match to <code>published</code> events</p>
<pre><code class="lang-ts">    <span class="hljs-keyword">new</span> codepipeline.CfnWebhook(<span class="hljs-built_in">this</span>, <span class="hljs-string">'WebhookResource'</span>, {
      authentication: <span class="hljs-string">'GITHUB_HMAC'</span>,
      authenticationConfiguration: {
        secretToken: SecretValue.secretsManager(<span class="hljs-string">'GITHUB_TEST_PIPELINE'</span>).toString(),
      },
      filters: [
        {
          jsonPath: <span class="hljs-string">'$.action'</span>,
          matchEquals: <span class="hljs-string">'published'</span>,
        },
      ],
      targetAction: ghAction.actionProperties.actionName,
      targetPipeline: myPipeLine.codePipeline.pipelineName,
      targetPipelineVersion: <span class="hljs-number">1</span>,
      registerWithThirdParty: <span class="hljs-literal">true</span>,
    });
</code></pre>
<h4 id="heading-tips">Tips</h4>
<ul>
<li>After initial deploy remember to edit the webhook in github to send <code>release</code> not <code>push</code> events!</li>
<li>Cloudformation deploy errors maybe based on github credentials access - make sure token valid and has permissions to create a webhook (admin I believe)</li>
</ul>
<h4 id="heading-useful-links">Useful links</h4>
<ul>
<li>https://stackoverflow.com/questions/52516087/trigger-aws-codepipeline-by-github-release-webhook</li>
<li>https://www.linkedin.com/pulse/aws-codepipeline-github-releases-geo-nicolaidis/</li>
<li>https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release</li>
<li>https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-webhook.html</li>
</ul>
]]></content:encoded></item></channel></rss>