{"id":23338394,"url":"https://github.com/abhirockzz/fn-github-webhook-twitter","last_synced_at":"2026-05-17T06:38:42.853Z","repository":{"id":79124960,"uuid":"156777108","full_name":"abhirockzz/fn-github-webhook-twitter","owner":"abhirockzz","description":"Fn function which tweets out new release info for your GitHub project","archived":false,"fork":false,"pushed_at":"2018-11-09T06:48:50.000Z","size":459,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T04:54:39.273Z","etag":null,"topics":["faas","fnproject","github","golang","serverless","twitter","webhook"],"latest_commit_sha":null,"homepage":"https://medium.com/fnproject/function-al-webhooks-with-fn-b7171a0fd004","language":"Go","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/abhirockzz.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":"2018-11-08T22:26:20.000Z","updated_at":"2021-04-18T06:32:41.000Z","dependencies_parsed_at":"2023-03-12T06:43:19.257Z","dependency_job_id":null,"html_url":"https://github.com/abhirockzz/fn-github-webhook-twitter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abhirockzz/fn-github-webhook-twitter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-github-webhook-twitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-github-webhook-twitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-github-webhook-twitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-github-webhook-twitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abhirockzz","download_url":"https://codeload.github.com/abhirockzz/fn-github-webhook-twitter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abhirockzz%2Ffn-github-webhook-twitter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018118,"owners_count":26086280,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["faas","fnproject","github","golang","serverless","twitter","webhook"],"created_at":"2024-12-21T03:13:47.674Z","updated_at":"2025-10-14T06:14:08.862Z","avatar_url":"https://github.com/abhirockzz.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"*\"Webhooks allow you to build or set up GitHub Apps which subscribe to certain events on GitHub.com. When one of those events is triggered, we'll send a HTTP POST payload to the webhook's configured URL\"*\r\n\r\nThis is a [Fn](https://github.com/fnproject/cli) function (written in **Go**) which acts as a GitHub webhook. Once configured and deployed\r\n\r\n- it will be invoked in response to a new release in a GitHub repo \r\n\r\n![](images/rel_.JPG)\r\n\r\n\r\n- and post release details (repo, version and access link) to Twitter\r\n\r\n![](images/success_tweet.JPG)\r\n\r\n\u003e the function in this example is configured to respond to GitHub releases, but the same can be extended/applied to other events such as pull requests, commits etc.\r\n\r\n## To start with...\r\n\r\nYou will need\r\n\r\n- [Twitter](https://twitter.com/) account\r\n- [GitHub](https://github.com/) account\r\n\r\n### Twitter app setup\r\n\r\nFollow [these instructions](https://apps.twitter.com/). You'll need `Consumer Key` (API Key), `Consumer Secret` (API Secret), `Access Token` and `Access Token Secret` for your function\r\n\r\n### GitHub setup\r\n\r\nFeel free to use an existing GitHub repository if you have one. I would recommend setting up a dummy repo to test things out\r\n\r\n## Deploy the function\r\n\r\n- get latest and greatest **Fn**\r\n    - [Fn CLI](https://github.com/fnproject/cli) - `curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh`\r\n    - Fn server - `fn update server`\r\n\r\n\u003e Make sure you have **Fn** installed on a machine which can be accessed from public Internet (e.g. a VM), or use [ngrok](https://ngrok.com/) on your local machine to set up a secure tunnel to your `localhost`\r\n\r\n- start Fn server - `fn start`\r\n- clone this repo\r\n- `cd fn-github-webhook-twitter`\r\n- create the app - `fn create app --config twitter_consumerkey=\u003ctwitter_consumerkey\u003e --config twitter_consumersecret=\u003ctwitter_consumersecret\u003e --config twitter_accesstoken=\u003ctwitter_accesstoken\u003e --config twitter_accesstokensecret=\u003ctwitter_accesstokensecret\u003e --config github_webhook_secret=\u003cgithub_webhook_secret\u003e fn-webhook-app` \r\n\r\ne.g. `fn create app --config twitter_consumerkey=foo --config twitter_consumersecret=bar --config twitter_accesstoken=red-me --config twitter_accesstokensecret=s3cr3t --config github_webhook_secret=kehsihba fn-webhook-app`\r\n\r\n\u003e value for `github_webhook_secret` is used as the `Secret` for GitHub webhook configuration in next step (section)\r\n\r\n- deploy the function - `fn -v deploy --app fn-webhook-app --local`\r\n\r\nYou should see an output similar to below..\r\n\r\n\r\n    ...\r\n    Updating function github-release-handler using image github-release-handler:0.0.2...\r\n    Successfully created app:  fn-webhook-app\r\n    Successfully created function: github-release-handler with github-release-handler:0.0.2\r\n    Successfully created trigger: handle-release\r\n    Trigger Endpoint: http://localhost:8080/t/fn-webhook-app/handle-release\r\n\r\n\u003e note down the `Trigger Endpoint`\r\n\r\n## Configure GitHub webhook\r\n\r\nYou can use the UI `Settings \u003e Webhooks` section of your repository to get started - details in [Github docs](https://developer.github.com/)\r\n\r\nWe'll use the [GitHub REST API](https://developer.github.com/v3/repos/hooks/#create-a-hook) for now\r\n\r\n\u003e I used OAauth token over Basic Authentication via REST API. You can read up on this and more [over here](https://developer.github.com/v3/auth/)\r\n\r\nHere is en example cURL command with the payload\r\n\r\n\r\n\tcurl -X POST -u \u003cgithub_user_id\u003e:\u003cyour_github_token_or_password\u003e \\\r\n\t  https://api.github.com/repos/\u003cgithub_user\u003e/\u003cgithub_repo\u003e/hooks \\\r\n\t  -H 'content-type: application/json' \\\r\n\t  -d '{\r\n\t  \"name\": \"web\",\r\n\t  \"active\": true,\r\n\t  \"events\": [\r\n\t    \"release\"\r\n\t  ],\r\n\t  \"config\": {\r\n\t    \"url\": \"\u003cfn_function_endpoint\u003e\",\r\n\t    \"secret\": \"\u003cyour_github_webhook_secret\u003e\",\r\n\t    \"content_type\": \"json\",\r\n\t    \"insecure_ssl\": 1\r\n\t  }\r\n\t}'\r\n\r\nReplace the following parameters as per your setup\r\n\r\n- `github_user_id` - user ID\r\n- `your_github_token_or_password` - OAuth token or password\r\n- `github_user` - user name\r\n- `github_repo` - repository for which webhook is being configured\r\n- `your_github_webhook_secret` - use the value which you used for `github_webhook_secret` while creating the function (`fn create...`)\r\n- `fn_function_endpoint` - enter the Fn function trigger endpoint e.g. `http://\u003cyour_fn_server_IP\u003e:8080/t/fn-webhook-app/handle-release`\r\n\r\nOnce completed, the new webhook should show up in the UI `Settings \u003e Webhooks` section\r\n\r\n![](images/hook4.jpg)\r\n\r\n## Test\r\n\r\n### Create a release\r\n\r\nWe'll use [the REST API](https://developer.github.com/v3/repos/releases/#create-a-release)\r\n\r\n\tcurl -X POST -u \u003cgithub_user_id\u003e:\u003cyour_github_token_or_password\u003e \\\r\n\t  https://api.github.com/repos/\u003cgithub_user\u003e/\u003cgithub_repo\u003e/releases \\\r\n\t  -H 'content-type: application/json' \\\r\n\t  -d '{\r\n\t  \"tag_name\": \"v1.0.0\",\r\n\t  \"target_commitish\": \"master\",\r\n\t  \"name\": \"v1.0.0\",\r\n\t  \"body\": \"Description of the release\",\r\n\t  \"draft\": false,\r\n\t  \"prerelease\": false\r\n\t}'\r\n\r\nYou should see the new release in the UI under `https://github.com/\u003cuser\u003e/\u003crepo\u003e/releases` \r\n\r\n![](images/rel_.JPG)\r\n\r\n### Check twitter\r\n\r\nYou should see the tweet\r\n\r\n![](images/success_tweet.JPG)\r\n\r\n### Check GitHub\r\n\r\nUnder repo `Settings \u003e Webhooks`, search the one you configured and see the `Recent Deliveries` section. You'll see a `HTTP 200` (from Fn function) along with the tweet text\r\n\r\n![](images/success_ghub.jpg)\r\n\r\n### Problems\r\nIn case there is an issue with Twitter creds, tweets won't get posted. This will result in `HTTP 500` from Fn function\r\n\r\n![](images/error.jpg)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhirockzz%2Ffn-github-webhook-twitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhirockzz%2Ffn-github-webhook-twitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhirockzz%2Ffn-github-webhook-twitter/lists"}