{"id":24835769,"url":"https://github.com/tobilg/serverless-twitter-bot","last_synced_at":"2025-03-26T03:40:21.280Z","repository":{"id":86825952,"uuid":"419738235","full_name":"tobilg/serverless-twitter-bot","owner":"tobilg","description":"An example application which tweets GitHub repo releases","archived":false,"fork":false,"pushed_at":"2022-10-20T16:18:18.000Z","size":451,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-31T04:51:43.692Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/tobilg.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-21T13:38:45.000Z","updated_at":"2021-10-22T06:55:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"41513f51-7b60-4661-93db-e6c5cc65ab87","html_url":"https://github.com/tobilg/serverless-twitter-bot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fserverless-twitter-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fserverless-twitter-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fserverless-twitter-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobilg%2Fserverless-twitter-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobilg","download_url":"https://codeload.github.com/tobilg/serverless-twitter-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245585807,"owners_count":20639671,"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":[],"created_at":"2025-01-31T04:51:43.598Z","updated_at":"2025-03-26T03:40:21.273Z","avatar_url":"https://github.com/tobilg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serverless-twitter-bot\nAn example application which tweets GitHub repo releases, running on AWS Lambda, EventBridge, SNS and DynamoDB. Built with the [Serverless framework](https://goserverless.com).\n\n## Architecture\n\n![Architecture diagram](docs/images/architecture.png)\n\n## How does the project work?\nThis project pulls a repository's relese or tag information from the GitHub GraphQL API, checks whether there are new releases, and if there are, tweets them out with a standardized tweet message linking to the GitHub release page.\n\nAs we want to compare existing (history) releases/tags with new ones, the architecture has two different \"streams\" which create/load repository information.\n\n* The repo histories needs to be loaded to be able to check for new versions (see below). The info about the release versions will be stored in DynamoDB.\n* There's a recurrent trigger which runs every 10min, and will create SNS messages, one per repo, which are then consumed by another function which queries the GitHub GraphhQL API for the release/tag info, compare the result to what is currently stored in the DynamoDB table, and insert new records\n\nAnother Lambda function will consume the DynamoDB stream's INSERT records, and use the contained information to send out the respective tweets\n\n## Preparations\nThere are several steps you have to take until you can launch this application.\n### Create a Twitter app to receive an API key and Access Token\nGo to [developer.twitter.com](https://developer.twitter.com/), create a new project and a new app. Probably you have to fill out their survey for new application. \n\n**Make sure you use your desired Twitter account before you create the app! Creating a separate Twitter account before using this application is recommended.**\n\nIt can take 1-2 days until you'll receive a feedback for your new application from Twitter.\n### Create a GitHub Access Token\nAs we're pulling repository releases via the GitHub GraphQL API, you'll need a GitHub Access Token for this project. Have a look at the [GitHub docs](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) about how you can do this.\n\n### Clone the project\n\n```bash\n$ git clone git@github.com:tobilg/serverless-twitter-bot.git \u0026\u0026 cd serverless-twitter-bot\n```\n### Prepare a .env file\nYou need to add the gathered information of the last steps to create a new `.env` file in the cloned project's root folder with the following structure:\n\n```bash\n# GitHub credentiatials\nGITHUB_ACCESS_TOKEN=\n\n# Twitter credentiatials\nTWITTER_CONSUMER_KEY=\nTWITTER_CONSUMER_SECRET=\nTWITTER_ACCESS_TOKEN=\nTWITTER_ACCESS_TOKEN_SECRET=\n```\n\nYou can get the information from the GitHub profile page, and the acording Twitter application settings.\n\n### Configure the repositories you're interested in\nTo configure the repositories you want to twwet release updates from, you can adapt the `repos` array in the [src/lib/repos.js](src/lib/repos.js#L20). By default, the AWS JS SDK is used as example repo.\n\nThe create a new entry, you should use the following structure:\n\n```javascript\n{\n  description: \"AWS SDK for Javascript\",\n  gitHubOrganizationName: \"aws\",\n  gitHubRepoName: \"aws-sdk-js\",\n  gitHubDataType: \"releases\",\n  filter: \"no-prerelease\"\n}\n```\n\nThe most important properties are `gitHubOrganizationName` (the organization/user name), and the `gitHubRepoName` (the name of the actual repo). E.g. if the repository URL is `https://github.com/aws/aws-sdk-js`, then the `gitHubOrganizationName` would be `aws` and the `gitHubRepoName` would be `aws-sdk-js`.\n\nThe `gitHubDataType` can be used to distinguish between `releases` or `tags`. To filter out pre-releases, you can apply the `filter` property as shown above.\n## Deployment\n\n### Deploy to AWS\nIf you have installed the Serverless framework (and configured the AWS accordingly), as well as having finalized all the preparations above, you can deploy the stack:\n\n```bash\n$ sls deploy\n```\n\n### Trigger initial history load\nTo be able to compare the potential new releases/tags, the history needs to be loaded (once and manually), by issueing\n\n```bash\n$ sls invoke -f createHistoryQueries\n```\n\nThis can take a while, depending on how many repos you configured, and how many releases/tags their are having.\n\n### Check if everything works\nIf everything works as desired, you should automatically see the tweets created automatically by this project.\n\nYou can also check the logs with\n\n```bash\n$ sls logs -f $FUNCTIONNAME\n```\n\nand check the entries in the respective DynamoDB table.\n\n### Feeback\nFeel free to create an issue if you encounter any problems with this project.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobilg%2Fserverless-twitter-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobilg%2Fserverless-twitter-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobilg%2Fserverless-twitter-bot/lists"}