{"id":21075269,"url":"https://github.com/maxking/mailmania-bot","last_synced_at":"2025-12-28T20:53:53.993Z","repository":{"id":141775796,"uuid":"108342060","full_name":"maxking/mailmania-bot","owner":"maxking","description":"Gitlab Bot to backport merge requests to stable release branches.","archived":false,"fork":false,"pushed_at":"2017-10-30T19:19:01.000Z","size":73,"stargazers_count":2,"open_issues_count":6,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T22:51:01.507Z","etag":null,"topics":["automation","aws","aws-apigateway","aws-lambda","backport","bot","chalice","cloud","git-tools","git-workflow","gitlab","python","python3","python36","serverless","serverless-examples","tools-engineering"],"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/maxking.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":"2017-10-26T00:36:42.000Z","updated_at":"2019-01-22T01:52:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"f18b6004-1892-470f-9f58-b899b83e3989","html_url":"https://github.com/maxking/mailmania-bot","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxking%2Fmailmania-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxking%2Fmailmania-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxking%2Fmailmania-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxking%2Fmailmania-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxking","download_url":"https://codeload.github.com/maxking/mailmania-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243521162,"owners_count":20304183,"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":["automation","aws","aws-apigateway","aws-lambda","backport","bot","chalice","cloud","git-tools","git-workflow","gitlab","python","python3","python36","serverless","serverless-examples","tools-engineering"],"created_at":"2024-11-19T19:20:54.478Z","updated_at":"2025-12-28T20:53:53.956Z","avatar_url":"https://github.com/maxking.png","language":"Python","readme":"# Mailmania Bot\n\n[![Build Status](https://travis-ci.org/maxking/mailmania-bot.svg?branch=master)](https://travis-ci.org/maxking/mailmania-bot)  [![codecov](https://codecov.io/gh/maxking/mailmania-bot/branch/master/graph/badge.svg)](https://codecov.io/gh/maxking/mailmania-bot) [![Maintainability](https://api.codeclimate.com/v1/badges/e3f01787574ccbca5bba/maintainability)](https://codeclimate.com/github/maxking/mailmania-bot/maintainability)\n\nThis bot is meant to help with backporting merge requests to branches other than\n'master'. It is built using server application framework [Chalice][3] hosted on\n[AWS Lambda][1] and receives notifications using [Gitlab's Webhooks][2].\n\n\n**Note** : This is a alpha quality software and is under active development. \n**Please use it at your own risk.**\n\n\n## Setup\n\nThis bot is not specific to any project and (minus some bugs) can be run for any\nproject on Gitlab.com. In future, I am planning to add support for\nnon-Gitlab.com instances of Gitlab and Github too, but there is not ETA. If\nyou'd like to help, please feel free to send in a pull request.\n\n\nIf you are not familiar with Chalice, I recommend that you look through its\n[documentation][4] to make sure you understand what are you doing. You need to\n[setup AWS credentials][5] on your local machine to be able to deploy to AWS Lambda\nusing Chalice. \n\n### Chalice Configuration\n\nThen, go ahead and clone this repo:\n\n```bash\n$ git clone https://github.com/maxking/mailmania-bot.git\n```\n\nCreate a new configuration file at `mailmania-bot/.chalice/config.json`:\n\n```json\n{\n  \"version\": \"2.0\",\n        \"app_name\": \"mailmania\",\n        \"environment_variables\": {\"\u003cproject_name\u003e_GL_TOKEN\": \"\u003csecret-token\u003e\",\n                                  \"GITLAB_TOKEN\": \"\u003cgitlab-access-token\u003e\",\n                                  \"BACKPORT_DESTINATION\": \"\u003cbackport-branch\u003e\",\n                                  \"ADMIN_EMAIL\": \"maxking@asynchronous.in\"},\n        \"stages\": {\n                \"dev\": {\n                        \"api_gateway_stage\": \"api\"\n                }\n        }\n}\n```\n\nThe environment variables in above configuration are meant to pass credentials\nto the Lambda Function as environment variables:\n\n- `\u003cproject_name\u003e_GL_TOKEN` : This is a secret token you set in Gitlab when\n  creating the Webhook to make sure your bot doesn't serve random web requests\n  from un-intended users. Please replace `\u003cproject_name\u003e` with the name of your\n  project without the namespace. So for https://gitlab.com/maxking/mailman you\n  will set `MAILMAN_GL_TOKEN`.\n  \n- `GITLAB_TOKEN`: This is the [personal access token][6] for your Gitlab User\n  which has enough permissions to create branches in the project that webhook in\n  set for. Merge requests will be created by this user.\n  \n- `BACKPORT_DESTINATION`: For now, this bot can only backport to a single branch\n  whose name is set as the value of this environment variable. Merge Requests\n  with label \"backport-candidate\" only are processed by this bot.\n  \n- `ADMIN_EMAIL`: In case anything goes wrong, an email will be sent to this\n  email address with error trace. Currently, this doesn't work properly.\n\n- `DEFAULT_FROM_EMAIL`: The From address to send emails from.\n\n\n### Deploying\n\nDeployment step for this bot:\n\n1. Create a virtual environment using Python 3.6:\n\n   ```bash\n   $ virtualenv -p python3.6 aws-chalice\n   $ aws-chalice/bin/activate\n   ```\n\n2. Install chalice and dependencies in your virtual environment:\n\n\t```bash\n\t$ pip install chalice\n\t$ pip install -r requirements.txt\n\t```\n\n3. Deploy to AWS lambda:\n\n\t```bash\n\t$ chalice deploy\n\t```\n\t\n\tThe above command should create appropriate policies for AWS IAM (for Lambda\n    Function), AWS SES (to send emails), AWS API Gateway, setup API gateway\n    endpoints for your project and push your packaged virtual environment to AWS\n    Lambda.\n\t\n\tThe above command will also give you endpoint where your bot will listen for\n    requests. You will need this in next step to setup the Gitlab's Webhook.\n\t\n\t**Note**: Sometimes, you may get `Module 'gitlab' not found` or similar\n    errors for dependencies. Please de-activate and re-activate your virtualenv\n    to fix this. I am not sure about the exact reason for this problem.\n\nI recommend reading [Chalice's Quickstart][7] and [documentation][4] for more\ndetailed instructions.\n\n\n### Gitlab Setup\n\nNow, you need to add a webhook in your Gitlab project to send a POST to the URL\nyou received in the previous step after running `chalice deploy` command.\n\nYou will also need a long random token which you added in the configuration\nabove to make sure only requests from Gitlab project are processed by the\nBot. Add this token under \"Secret Token\" in add web hook form.\n\nCheck only \"Merge Request events\" in the list of events. \n\nFinally, save your webhook.\n\n\n## Process of creating Merge Request\n\nThis is the steps bot does to create a backported merge request:\n\n1. Create a new branch with `BACKPORT_DESTINATION` branch as the reference.\n2. Cherry-pick all the commits from the MR being backported.\n3. Create a new MR from this new branch to the `BACKPORT_DESTINATION` branch.\n\n\n## Contributing Guidelines\n\nContributions and questions are welcome. Please create a issue on the Github\nproject.\n\n\n## License\n\nThis project is Licensed under Apache License 2.0. Please see the LICENSE file\nfor full license text.\n\n\n\n[1]: https://aws.amazon.com/lambda/\n[2]: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html\n[3]: https://github.com/aws/chalice\n[4]: https://chalice.readthedocs.io/en/latest/index.html\n[5]: https://github.com/aws/chalice#credentials\n[6]: https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html\n[7]: https://github.com/aws/chalice#quickstart\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxking%2Fmailmania-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxking%2Fmailmania-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxking%2Fmailmania-bot/lists"}