{"id":16293940,"url":"https://github.com/sambaiz/cdkbot","last_synced_at":"2025-03-20T04:30:26.219Z","repository":{"id":41763806,"uuid":"198790689","full_name":"sambaiz/cdkbot","owner":"sambaiz","description":"AWS CDK review \u0026 deploy tool working on Pull Request","archived":false,"fork":false,"pushed_at":"2024-02-06T06:38:28.000Z","size":5203,"stargazers_count":6,"open_issues_count":16,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T14:22:12.270Z","etag":null,"topics":["aws","aws-cdk","devops","infrastructure-as-code"],"latest_commit_sha":null,"homepage":"","language":"Go","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/sambaiz.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}},"created_at":"2019-07-25T08:30:03.000Z","updated_at":"2025-03-06T19:53:50.000Z","dependencies_parsed_at":"2024-02-06T07:45:03.461Z","dependency_job_id":null,"html_url":"https://github.com/sambaiz/cdkbot","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambaiz%2Fcdkbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambaiz%2Fcdkbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambaiz%2Fcdkbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambaiz%2Fcdkbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sambaiz","download_url":"https://codeload.github.com/sambaiz/cdkbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244551780,"owners_count":20470915,"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","aws-cdk","devops","infrastructure-as-code"],"created_at":"2024-10-10T20:13:15.641Z","updated_at":"2025-03-20T04:30:25.696Z","avatar_url":"https://github.com/sambaiz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cdkbot\n\ncdkbot is AWS CDK review \u0026 deploy tool working on Pull Request.\nCurrently only GitHub is supported.\n\n## Commands\n\nFollowing commands are runnable by PR comments. \nBefore running a command, base (where to merge) branch is merged internally \nso it is needed to resolve conflicts if it occurred.\n\n- `/diff`: cdk diff all stacks. Run automatically when open PR and push to PR.\n- `/deploy [stack1 stack2 ...]`: \ncdk deploy. If not specify stacks, all stacks are passed. \nAfter running, PR is merged automatically if there are no differences anymore.\n\n- `/rollback [stack1 stack2 ...]`: \ncdk deploy at base branch. If not specify stacks, all stacks are passed. \nOnly deployed PR can be roll backed.\n\n![run /diff and /deploy](./doc-assets/run-diff-deploy.png)\n\n## Label\n\n- `cdkbot:running`: Command is running. \n- `cdkbot:deployed`: \nAdded when running /deploy. \nAs long as this PR is open for deploying partial stacks etc., no other PR with the same base branch can be deployed.\nRunning /rollback can remove this.\n\n- `cdkbot:outdated diffs`: \nAdded when merging other PR. \nThis force to see the latest diffs by running /diff before running /deploy on the PRs with the same base branch.\n\n![oudated diffs label](./doc-assets/outdated-diffs.png)\n\n## Install \u0026 Settings\n\n### Install\n\n```\n$ make deploy S3Bucket=*** \\ \n              SubnetID=subnet-***** \\ \n              Platform=github GitHubUserName=*** \\ \n              GitHubAccessToken=*** \\ \n              GitHubWebhookSecret=***\n```\n\n- GitHubUserName \u0026 GitHubAccessToken\n\nToken can be generated at `Settings/Developer settings`.\nrepo and write:discussion scopes are required.\n\n- GitHubWebhookSecret: Generate a random string.\n- Platform: Only `github`.\n- SubnetID: an exist Subnet ID for running tasks on ECS fargate.\n\n\n### cdkbot.yml\n\nPut `cdkbot.yml` at the repository root. \ncdkbot refer to the base branch's cdkbot.yml and cdk.json for security and authority reasons \nso it's needed to be merged to apply the changes.\n\n```\ncdkRoot: . # Relative path of the directory where cdk.json exists\ntargets:\n  # If any key is matched the PR base branch, run commands with contexts `-c key=value`.\n  # If not, commands are not runned.\n  develop:\n    contexts:\n      env: stg\n  master:\n    contexts:\n      env: prd\npreCommands:\n  # Optional. Run before command.\n  - npm run build\ndeployUsers:\n  # Optional. If specified, only these users are allowed to deploy.\n  # If not, all users are allowed to deploy.\n  - sambaiz\n```\n\n### Repository settings\n\nAdd a webhook at repository's settings. \n\n- Payload URL: See CloudFormation Stack output\n- Content type: application/json \n- Secret: same value of GitHubWebhookSecret\n- Event trigger: Pushes, Issue comments and Pull requests\n\nAfter the first run, enable \"Require status checks to pass before merging\" \nin the branch protection rule to prevent merging before deploying (Recommended)\n\n## Why deploys before merging PR?\n\ncdk deploy sometimes fails unexpectedly due to runtime errors of CFn template.\nTherefore, if deploys after merging PR, \nbroken codes can be merged and surplus PRs are opened to revert or fix, which flagment changes. \nIn addition, if there are dependencies between stacks, it is necessary to control the deploy order when deleting resources, \nbut to do that, it must specify the execution order beforehand somehow.\n\nDeploying before merging PR has the advantage of resolving these issues but changes may be reverted.\nTo prevent this, cdkbot takes measures these:\n\n- base branch is merged internally before running a command, and deployed PR is merged automatically\n- sets the number of concurrent executions to 1\n- `cdkbot:deployed` label to avoid overwriting other PR deploy\n- `cdkbot:outdated diffs` label to force to see latest differences","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambaiz%2Fcdkbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsambaiz%2Fcdkbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambaiz%2Fcdkbot/lists"}