{"id":19129356,"url":"https://github.com/launchbynttdata/git-webhook-lambda","last_synced_at":"2026-05-08T04:19:42.177Z","repository":{"id":234078320,"uuid":"774583472","full_name":"launchbynttdata/git-webhook-lambda","owner":"launchbynttdata","description":"Lambda Function used as a Webhook target for v1 of Launch's AWS pipelines","archived":false,"fork":false,"pushed_at":"2025-04-22T17:37:47.000Z","size":46,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-04-22T18:46:02.901Z","etag":null,"topics":["git","github","lambda","platform-automation","webhook"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/launchbynttdata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-03-19T20:01:40.000Z","updated_at":"2025-01-14T19:36:35.000Z","dependencies_parsed_at":"2025-04-22T18:30:19.869Z","dependency_job_id":null,"html_url":"https://github.com/launchbynttdata/git-webhook-lambda","commit_stats":null,"previous_names":["launchbynttdata/git-webhook-lambda"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/launchbynttdata/git-webhook-lambda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Fgit-webhook-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Fgit-webhook-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Fgit-webhook-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Fgit-webhook-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/launchbynttdata","download_url":"https://codeload.github.com/launchbynttdata/git-webhook-lambda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/launchbynttdata%2Fgit-webhook-lambda/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263833411,"owners_count":23517371,"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":["git","github","lambda","platform-automation","webhook"],"created_at":"2024-11-09T06:07:16.583Z","updated_at":"2026-05-08T04:19:37.155Z","avatar_url":"https://github.com/launchbynttdata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Webhook for CodeBuild\n\nThe lambda function acts as a webhook to invoke a CodeBuild job\n\n## Create zip file to deploy to AWS Lambda\n```shell\nchmod +x build_deployable_zip.sh\n./build_deployable_zip.sh\n```\n## Handler\nThe name of the handler for this lambda is `codeBuildHandler.lambda_handler`\n## Lambda Environment variables\nThis lambda function requires that a few mandatory environment variables are passed in to the lambda function. Below are the list of environment variables\n```shell\n# A valid json parsable string\n# This example is for push event (repo:refs_changed)\nCODEBUILD_ENV_VARS_MAP={ \"REPOSITORY_URL\": \"repository.links.clone[name=http].href\", \"GIT_REF_ID\": \"changes[type=UPDATE].refId\", \"LATEST_COMMIT_HASH\": \"changes[type=UPDATE].toHash\", \"GIT_PROJECT\": \"repository.project.key\", \"GIT_REPO\": \"repository.slug\", \"BRANCH\": \"changes[type=UPDATE].ref.displayId\", \"EVENT_TYPE\": \"eventKey\", \"FROM_HASH\": \"changes[type=UPDATE].fromHash\", \"TO_HASH\": \"changes[type=UPDATE].toHash\" }\n# CodeBuild job to trigger\nCODEBUILD_PROJECT_NAME=bitbucket-codebuild-webhook\n# URL of the CodeBuild for the correct region\nCODEBUILD_URL=https://us-east-2.console.aws.amazon.com/codesuite/codebuild/projects?region=us-east-2\n# Git Callback payload (to update the status of the webhook)\n# Below example is for BitBucket payload\nGIT_SECRET=\u003cgit_secret\u003e\n# URL of the Git provider URL\nGIT_SERVER_URL=https://bitbucket.example.com\n# Token/password to connect to git provider\nGIT_TOKEN=\u003cgit_token\u003e\n# Username to connect to git provider\nGIT_USERNAME=example\n# Logging level of lambda function (Optional). Default=INFO. Valid values (DEBUG, INFO, WARNING, ERROR, CRITICAL)\nLOGGING_LEVEL=DEBUG\n# Whether to validate the digital signature of the payload body. Default=false Header `x-hub-signature` contains the sha-256 signature to match\nVALIDATE_DIGITAL_SIGNATURE=true\n# Webhook Event type this lambda function will listen to (Valid values for BitBucket: repo:refs_changed, pr:opened, pr:updated, pr:merged)\n# Bitbucket event details: https://confluence.atlassian.com/bitbucketserver0721/event-payload-1115665959.html\nWEBHOOK_EVENT_TYPE=repo:refs_changed\n```\n\nThe following environment variables are optional if you wish to enable the codebuild build status callback feature. This does not work for github.\n```shell\nGIT_CALLBACK_PAYLOAD={\"state\": \"{{CODEBUILD_STATUS}}\", \"key\": \"{{CODEBUILD_PROJECT_NAME}}-{{LATEST_SHORT_HASH}}\", \"name\": \"{{CODEBUILD_PROJECT_NAME}}\", \"url\": \"{{CODEBUILD_URL}}\", \"description\": \"{{CALLBACK_DESCRIPTION}}\" }\n# Git Callback URI (to update the status of the webhook)\n# LATEST_COMMIT_HASH must be a key in CODEBUILD_ENV_VARS_MAP\n# Below example is for BitBucket callback URI\nGIT_CALLBACK_URI={{GIT_SERVER_URL}}/rest/build-status/1.0/commits/{{LATEST_COMMIT_HASH}}\n# Salt used to create digital signature. Required if VALIDATE_DIGITAL_SIGNATURE=true\n# For Bitbucket, this is configured while creating the webhook\n```\n\n## [Bitbucket] Webhook Events\nOur current plan supports the following webhook events\n- Push\n  - Event Type `repo:refs_changed`\n- PR Created\n  - Event Type `pr:opened`\n- PR Updated (source branch updated)\n  - Event Type `pr:from_ref_updated`\n- PR Merged\n  - Event Type `pr:merged`\n\n## [Github] Webhook Events\nOur current plan supports the following webhook events\n- Pull request\n  - Event Type `pull_request`\n- PR Merged\n  - Event Type `closed`\n- PR Updated (source branch updated)\n  - Event Type `synchronize`\n- PR Opened\n  - Event Type `opened`\n\n## CODEBUILD_ENV_VARS_MAP\nFor each Git event the webhook would respond to, the lambda function has to be configured with a `dictionary/map` environment variable. The key of the map would be the environment variable to be passed to the `CodeBuild job` and the value would be the path in the webhook payload where the value be fetched. \n\nListed below are examples of the `CODEBUILD_ENV_VARS_MAP` for BitBucket events that will be supported in our project\n\n### [Bitbucket] Push\n```shell\n{\n    \"REPOSITORY_URL\": \"repository.links.clone[name=http].href\",\n    \"GIT_REF_ID\": \"changes[type=UPDATE].refId\",\n    \"LATEST_COMMIT_HASH\": \"changes[type=UPDATE].toHash\",\n    \"GIT_PROJECT\": \"repository.project.key\",\n    \"GIT_REPO\": \"repository.slug\",\n    \"BRANCH\": \"changes[type=UPDATE].ref.displayId\",\n    \"EVENT_TYPE\": \"eventKey\",\n    \"FROM_HASH\": \"changes[type=UPDATE].fromHash\",\n    \"TO_HASH\": \"changes[type=UPDATE].toHash\"\n}\n```\n\n## [Bitbucket] PR Opened\n```shell\n{\n    \"REPOSITORY_URL\": \"pullRequest.fromRef.repository.links.clone[name=http].href\",\n    \"GIT_FROM_REF_ID\": \"pullRequest.fromRef.id\",\n    \"GIT_TO_REF_ID\": \"pullRequest.toRef.id\",\n    \"LATEST_COMMIT_HASH\": \"pullRequest.fromRef.latestCommit\",\n    \"GIT_PROJECT\": \"pullRequest.fromRef.repository.project.key\",\n    \"GIT_REPO\": \"pullRequest.fromRef.repository.slug\",\n    \"FROM_BRANCH\": \"pullRequest.fromRef.displayId\",\n    \"TO_BRANCH\": \"pullRequest.toRef.displayId\",\n    \"EVENT_TYPE\": \"eventKey\"\n}\n```\n\n## [Bitbucket] PR Updated\n```shell\n{\n    \"REPOSITORY_URL\": \"pullRequest.fromRef.repository.links.clone[name=http].href\",\n    \"GIT_FROM_REF_ID\": \"pullRequest.fromRef.id\",\n    \"GIT_TO_REF_ID\": \"pullRequest.toRef.id\",\n    \"LATEST_COMMIT_HASH\": \"pullRequest.fromRef.latestCommit\",\n    \"GIT_PROJECT\": \"pullRequest.fromRef.repository.project.key\",\n    \"GIT_REPO\": \"pullRequest.fromRef.repository.slug\",\n    \"FROM_BRANCH\": \"pullRequest.fromRef.displayId\",\n    \"TO_BRANCH\": \"pullRequest.toRef.displayId\",\n    \"EVENT_TYPE\": \"eventKey\"\n    \"PREVIOUS_FROM_HASH\": \"previousFromHash\"\n}\n```\n\n## [Bitbucket] PR Merged\n```shell\nTBD. Dont have one yet\n```\n\n## [Github] Pull request\n```shell\n{\n    \"SOURCE_REPO_URL\": \"repository.clone_url\",\n    \"FROM_BRANCH\": \"pull_request.head.ref\",\n    \"TO_BRANCH\": \"pull_request.base.ref\",\n    \"MERGE_COMMIT_ID\": \"pull_request.head.sha\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchbynttdata%2Fgit-webhook-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchbynttdata%2Fgit-webhook-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchbynttdata%2Fgit-webhook-lambda/lists"}