{"id":19039510,"url":"https://github.com/awesome-cdk/cdk-report-codepipeline-status-to-github","last_synced_at":"2026-04-06T10:01:43.064Z","repository":{"id":57100026,"uuid":"411208049","full_name":"awesome-cdk/cdk-report-codepipeline-status-to-github","owner":"awesome-cdk","description":"AWS CDK Construct that, when attached to a CodePipeline, will report back to GitHub (using the GitHub Status API), whenever the CodePipeline succeeds or fails","archived":false,"fork":false,"pushed_at":"2022-12-06T22:40:53.000Z","size":619,"stargazers_count":12,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-18T05:53:43.499Z","etag":null,"topics":["aws-cdk","aws-codepipeline","github-api"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@awesome-cdk/cdk-report-codepipeline-status-to-github","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awesome-cdk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-28T09:00:25.000Z","updated_at":"2025-02-22T15:11:00.000Z","dependencies_parsed_at":"2023-01-24T11:46:06.268Z","dependency_job_id":null,"html_url":"https://github.com/awesome-cdk/cdk-report-codepipeline-status-to-github","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-cdk%2Fcdk-report-codepipeline-status-to-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-cdk%2Fcdk-report-codepipeline-status-to-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-cdk%2Fcdk-report-codepipeline-status-to-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awesome-cdk%2Fcdk-report-codepipeline-status-to-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awesome-cdk","download_url":"https://codeload.github.com/awesome-cdk/cdk-report-codepipeline-status-to-github/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250513665,"owners_count":21443203,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-cdk","aws-codepipeline","github-api"],"created_at":"2024-11-08T22:17:15.213Z","updated_at":"2026-04-06T10:01:43.060Z","avatar_url":"https://github.com/awesome-cdk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Report CodePipeline build status to GitHub commit\n\n![CI status](https://github.com/awesome-cdk/cdk-report-codepipeline-status-to-github/actions/workflows/npm.yml/badge.svg)\n[![npm version](https://badge.fury.io/js/@awesome-cdk%2Fcdk-report-codepipeline-status-to-github.svg)](https://badge.fury.io/js/@awesome-cdk%2Fcdk-report-codepipeline-status-to-github)\n\n\nAn AWS CDK construct that, when attached to a CodePipeline, will make sure success or failure of that pipeline is\nreflected back to GitHub and shown next to the commit.\n\nThis is largely based on\nthe \u003ca href=\"https://aws.amazon.com/blogs/devops/aws-codepipeline-build-status-in-a-third-party-git-repository/\"\u003e\nreference architecture, proposed by AWS\u003c/a\u003e, minus the SNS topic, since it's not really needed.\n\n```mermaid\nflowchart LR\n    A[\"👨‍💻 Developer pushes commit\"] --\u003e B[\"GitHub Repository\"]\n    B --\u003e C[\"AWS CodePipeline\"]\n    C --\u003e|Pipeline status changes| D[\"Amazon EventBridge\"]\n    D --\u003e|Triggers| E[\"AWS Lambda\"]\n    E --\u003e|Reads commit details| C\n    E --\u003e|Reports build status| B\n```\n\u003cimg width=\"1393\" height=\"598\" alt=\"image\" src=\"https://github.com/user-attachments/assets/36112e2b-5b68-4481-ba0c-e278b5433e7f\" /\u003e\n\n\n### Migrating from v1 (CDK v1) to v2 (CDK v2)\n\nThis package was rewritten for AWS CDK v2. If upgrading from an earlier version:\n\n- Replace all `@aws-cdk/*` imports with `aws-cdk-lib` equivalents\n- Add `constructs` as a dependency (`Construct` now comes from the `constructs` package)\n- The public API (`CodePipelinePostToGitHub` class and its props) is unchanged\n\n```diff\n- import {StringParameter} from \"@aws-cdk/aws-ssm\";\n+ import {StringParameter} from \"aws-cdk-lib/aws-ssm\";\n```\n\nThe same pattern applies to all other `@aws-cdk/*` imports (e.g. `@aws-cdk/aws-codepipeline` → `aws-cdk-lib/aws-codepipeline`).\n\n### Requirements\n\n- AWS CDK v2 (`aws-cdk-lib` \u003e= 2.100.0)\n- Node.js \u003e= 18\n\n### Quick Start\n\n```\nnpm i @awesome-cdk/cdk-report-codepipeline-status-to-github\n```\n\n```typescript\nimport {CodePipelinePostToGitHub} from \"@awesome-cdk/cdk-report-codepipeline-status-to-github\";\nimport {StringParameter} from \"aws-cdk-lib/aws-ssm\";\nimport * as codepipeline from \"aws-cdk-lib/aws-codepipeline\";\n\n// Create your pipeline with its Stages and all other configuration, as you would normally do it\nconst pipeline = new codepipeline.Pipeline(this, 'Pipeline', {});\n\n// Use the construct from this package, passing a \"Systems Manager - Parameter Store\" where you've previously stored your GitHub \"Personal Access Token\"\nconst githubToken = StringParameter.fromStringParameterName(this, 'GitHubToken', 'GITHUB_TOKEN');\nnew CodePipelinePostToGitHub(pipeline, 'CodePipelinePostToGitHub', {\n    pipeline,\n    githubToken,\n});\n```\n\n### E2E Testing\n\nAn end-to-end test script is included that creates a throwaway GitHub repo, deploys the construct to a real AWS account, triggers a pipeline, and verifies the commit status is reported back to GitHub.\n\n**Prerequisites:**\n\n- [gh CLI](https://cli.github.com/) authenticated (`gh auth login`)\n- AWS credentials in the shell (e.g. via `aws-vault`, `aws sso login`, or env vars)\n- Node.js \u003e= 18, pnpm installed\n- A **classic** GitHub PAT with `repo` scope (fine-grained PATs are not supported by CodePipeline's GitHub source action)\n\n**Run:**\n\n```bash\naws-vault exec \u003cprofile\u003e -- ./e2e.sh --github-pat ghp_xxx\n```\n\n**What it does:**\n\n1. Creates a throwaway public GitHub repo\n2. Pushes a test commit (via SSH)\n3. Deploys the CDK example stack (CodePipeline + Lambda + CloudWatch Event Rule)\n4. Starts the pipeline and waits for it to run\n5. Polls the GitHub commit status API until `success` or `failure` is reported\n6. Cleans up: destroys the stack, deletes the repo, removes the SSM parameter\n\n**Note:** If repo deletion fails (missing `delete_repo` scope), the script will print a link to delete it manually. To enable auto-deletion for future runs:\n\n```bash\ngh auth refresh -h github.com -s delete_repo\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawesome-cdk%2Fcdk-report-codepipeline-status-to-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawesome-cdk%2Fcdk-report-codepipeline-status-to-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawesome-cdk%2Fcdk-report-codepipeline-status-to-github/lists"}