{"id":15747803,"url":"https://github.com/developer-guy/faasd-github-bot","last_synced_at":"2025-06-28T23:34:15.777Z","repository":{"id":55500910,"uuid":"322846938","full_name":"developer-guy/faasd-github-bot","owner":"developer-guy","description":"Github application using Go, inlets + inlets-pro and faasd","archived":false,"fork":false,"pushed_at":"2020-12-26T12:57:35.000Z","size":825,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T14:04:24.801Z","etag":null,"topics":["exit-node","faasd","github-app","go","inlets","inlets-pro","openfaas"],"latest_commit_sha":null,"homepage":"","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/developer-guy.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}},"created_at":"2020-12-19T12:51:20.000Z","updated_at":"2021-08-04T14:00:42.000Z","dependencies_parsed_at":"2022-08-15T01:50:49.914Z","dependency_job_id":null,"html_url":"https://github.com/developer-guy/faasd-github-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/developer-guy%2Ffaasd-github-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer-guy%2Ffaasd-github-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer-guy%2Ffaasd-github-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/developer-guy%2Ffaasd-github-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/developer-guy","download_url":"https://codeload.github.com/developer-guy/faasd-github-bot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251666048,"owners_count":21624289,"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":["exit-node","faasd","github-app","go","inlets","inlets-pro","openfaas"],"created_at":"2024-10-04T05:21:55.577Z","updated_at":"2025-04-30T07:48:41.666Z","avatar_url":"https://github.com/developer-guy.png","language":"Go","readme":"# faasd-github-bot\n![github-issue-bot](images/faasd-issue-bot.png)\n\nTable of Contents\n=================\n\n* [faasd\\-github\\-bot](#faasd-github-bot)\n* [Table of Contents](#table-of-contents)\n    * [Description](#description)\n    * [Prerequisites](#prerequisites)\n        * [arkade](#arkade)\n        * [inletsctl](#inletsctl)\n        * [inlets\\-pro](#inlets-pro)\n        * [multipass](#multipass)\n        * [faas\\-cli](#faas-cli)\n    * [Setup exit\\-node server on AWS](#setup-exit-node-server-on-aws)\n    * [Setting up a new GitHub App](#setting-up-a-new-github-app)\n    * [Setup faasd](#setup-faasd)\n    * [Build\u0026amp;Deploy function](#builddeploy-function)\n    * [Connect your client to the inlets\\-pro server using inletsctl](#connect-your-client-to-the-inlets-pro-server-using-inletsctl)\n    * [Test](#test)\n    * [Cleanup](#cleanup)\n* [References](#references)\n\n\n### Description\nIn this demo, we are going to develop a Github application using Go, then we deploy it as a serverless function to make use of faasd which is a lightweight \u0026 portable faas engine.We are also going to do this demo on our local environment, so we should open our function which runs on our local environment to the Internet so Github can send events to our function.In order to do that we use inlets-pro which provides secure TCP/L4 tunnels.\n### Prerequisites\n\u003e We are going to run this demo on our macbook, but you can run the demo wherever you want.\n#### arkade\nYou can basically use arkade to install of these following tools, so we need to install arkade first.\narkade provides a portable marketplace for downloading your favourite devops CLIs and installing helm charts, with a single command.\n````bash\n$ curl -sLS https://dl.get-arkade.dev | sh\n$ arkade version\n            _             _\n  __ _ _ __| | ____ _  __| | ___\n / _` | '__| |/ / _` |/ _` |/ _ \\\n| (_| | |  |   \u003c (_| | (_| |  __/\n \\__,_|_|  |_|\\_\\__,_|\\__,_|\\___|\n\nGet Kubernetes apps the easy way\n\nVersion: 0.6.35\nGit Commit: df53c4f6d9c604186b36aae7f0feb1d39940be8f\n````\n#### inletsctl\nWe need inletsctl to automate the task of creating an exit-node on cloud infrastructure.\n````bash\n$ arkade get inletsctl\n$ inletsctl version\n _       _      _            _   _\n(_)_ __ | | ___| |_ ___  ___| |_| |\n| | '_ \\| |/ _ \\ __/ __|/ __| __| |\n| | | | | |  __/ |_\\__ \\ (__| |_| |\n|_|_| |_|_|\\___|\\__|___/\\___|\\__|_|\n\nVersion: 0.7.1\nGit Commit: 8641a9a09903f0e3b18a4ed1d388a35663a52dc4\n````\n#### inlets-pro\nWe need inlets-pro to tunnel out any TCP traffic from an internal network to another network.\n```bash\n$ inletsctl download --pro\n$ inlets-pro version\n _       _      _            _\n(_)_ __ | | ___| |_ ___   __| | _____   __\n| | '_ \\| |/ _ \\ __/ __| / _` |/ _ \\ \\ / /\n| | | | | |  __/ |_\\__ \\| (_| |  __/\\ V /\n|_|_| |_|_|\\___|\\__|___(_)__,_|\\___| \\_/\n\nPRO edition\n\nVersion: 0.7.2\nGit Commit: 5190eca94b4020ec8de47a22eb411bb17a995399\n```\n#### multipass\nWe need to provision ubuntu vm's to host our faasd.In order to do that multipass cli is the best tool.\n```bash\n$ brew install multipass\n$ multipass version\nmultipass  1.5.0+mac\nmultipassd 1.5.0+mac\n```\n#### faas-cli\nWe need faas-cli to interact with the gateway which runs on faasd.\n```bash\n$ arkade get faas-cli\n$ faas-cli version\n  ___                   _____           ____\n / _ \\ _ __   ___ _ __ |  ___|_ _  __ _/ ___|\n| | | | '_ \\ / _ \\ '_ \\| |_ / _` |/ _` \\___ \\\n| |_| | |_) |  __/ | | |  _| (_| | (_| |___) |\n \\___/| .__/ \\___|_| |_|_|  \\__,_|\\__,_|____/\n      |_|\n\nCLI:\n commit:  598336a0cad38a79d5466e6a3a9aebab4fc61ba9\n version: 0.12.21\n```\n\nNow we are ready to go 🚀\n\n### Setup exit-node server on AWS\nIn order to do that, we need two things: AWS Account and inletsctl. \u003cbr/\u003e\nFirst we need to get our access key ID and the secret access key from our AWS Account. \u003cbr/\u003e\nTo get your access key ID and secret access key:\n1. Open the IAM console.\n2. From the navigation menu, click Users.\n3. Select your IAM user name.\n4. Click User Actions, and then click Manage Access Keys.\n5. Click Create Access Key.\nYour keys will look something like this:\n* Access key ID example: AKIAIOSFODNN7EXAMPLE\n* Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\n6. Click Download Credentials, and store the keys in a secure location.\n\nThen, make use of the environment variables to securely store them.\n```bash\n$ export AWS_SECRET_KEY=\"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\n$ export AWS_ACCESS_KEY=\"AKIAIOSFODNN7EXAMPLE\"\n```\nFinally, start your exit-node server on the eu-central-1 region.\n```bash\n$ inletsctl create --provider ec2 --secret-key $AWS_SECRET_KEY --pro --access-token $AWS_ACCESS_KEY --region eu-central-1\nUsing provider: ec2\nRequesting host: charming-perlman2 in eu-central-1, from ec2\nHost: i-04510810d5aa67ba2, status: creating\n[1/500] Host: i-04510810d5aa67ba2, status: creating\n[2/500] Host: i-04510810d5aa67ba2, status: creating\n[3/500] Host: i-04510810d5aa67ba2, status: creating\n[4/500] Host: i-04510810d5aa67ba2, status: creating\n[5/500] Host: i-04510810d5aa67ba2, status: creating\n[6/500] Host: i-04510810d5aa67ba2, status: initialising\n...\ninlets PRO (0.7.0) exit-server summary:\n  IP: X.XXX.XXX.XXX\n  Auth-token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n\nCommand:\n  export LICENSE=\"\"\n  export PORTS=\"8000\"\n  export UPSTREAM=\"localhost\"\n\n  inlets-pro client --url \"wss://X.XXX.XXX.XX:8123/connect\" \\\n        --token \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXX\" \\\n        --license \"$LICENSE\" \\\n        --upstream $UPSTREAM \\\n        --ports $PORTS\n\nTo Delete:\n          inletsctl delete --provider ec2 --id \"i-04510810d5aa67ba2\"\n\n\n# Check your EC2 instances after the command by using aws-cli\n$ aws ec2 describe-instances --filters \"Name=instance-state-name,Values=running\" --query \"Reservations[].Instances[].InstanceId\" --no-cli-pager\ni-i-04510810d5aa67ba3\n```\n\n### Setting up a new GitHub App\n\nTo register a new app, visit the app settings page in your GitHub profile, and click New GitHub App.\n\n![register-github-app](images/register-github-app.png)\nYou'll see a form where you can enter details about your app. See \"Creating a GitHub App\" for general information about the fields on this page. For the purposes of this guide, you'll need to enter specific data in a few fields:\n\nFor more details you can check it out the [link](https://docs.github.com/en/free-pro-team@latest/developers/apps/setting-up-your-development-environment-to-create-a-github-app#step-2-register-a-new-github-app)\n\nThe most important parts of this form are \"Webhook URL,Webhook Secret and Private keys\":\n\n* Webhook URL --\u003e You should set the IP address of the output of the command above\n![webhook-url](./images/webhook-url.png)\n  \n* Webhook Secret --\u003e Define a secret for your Webhook\n![webhook-secret](./images/webhook-secret.png)\n  \n* Private Key --\u003e Generate and download private key for your Github Application\n![private-key](./images/private-keys.png)\n\n* Also, *do not forget to request permissions to Read \u0026 Write the repository's issues.*\n![issues](./images/permissions.png)\n  \nFinally, we registered our application\n![github-app](./images/app.png)\n  \n### Setup faasd\nIn order to get up and running with your own faasd installation on your Mac you can use multipass.\n\nLet's start our Ubuntu VM with multipass \u003cbr/\u003e\n\nFirst, we need a cloud-config.txt to set up faasd while bootstrapping VM\n```bash\n$ curl -sSLO https://raw.githubusercontent.com/openfaas/faasd/master/cloud-config.txt\n```\nThen, we need to update the SSH key to match your own, edit cloud-config.txt:\n```\n$ ssh-keygen -t rsa -b 4096 -C \"developerguyn@gmail.com\" -f $PWD/id_rsa\n```\n\nReplace the _ssh_authorized_keys::ssh-rsa_ value with the contents of `~/.ssh/id_rsa.pub`, which is defined in `cloud-config.txt`.\n\nFinally, boot the VM\n\n```bash\n$ multipass launch --cloud-init cloud-config.txt  --name faasd\n```\n\nCheck the VM if it is working properly\n```bash\n$ multipass list                                                                                                                                                                                             🐳(docker-desktop)\nName                    State             IPv4             Image\nfaasd                   Running           192.168.64.25    Ubuntu 20.04 LTS\n```\n\nFor more details you can check it out the [link](https://github.com/openfaas/faasd/blob/master/docs/MULTIPASS.md).\n\n### Build\u0026Deploy function\nIn this demo, we are going to use Go to develop our Github Application, in order to do that, first, we need to pull the corresponding function template for the Go.\n```bash\n# let's look at the available Go function templates within the OpenFaaS store\n$ faas-cli template store list | grep -i \"go\"\ngo                       openfaas           Classic Golang template\ngolang-http              openfaas           Golang HTTP template\ngolang-middleware        openfaas           Golang Middleware template\n# We are going to use golang-middleware function template, let's pull it.\n$ faas-cli template store pull golang-middleware\n# Then, create the function itself.\n$ faas-cli new issues-bot --lang golang-middleware --prefix \u003cDOCKER_HUB_ID\u003e\n```\nAfter created the function, we need to define some arguments, environments and secrets for the function.\nLet's add them:\n```yaml\n  build_args:\n      GO111MODULE: on\n    secrets:\n      - webhook-secret # your secret goes here\n      - private-key-secret # your private key goes here\n    environment:\n      APP_ID: \"\" #your app id goes here\n```\n\nFinally, we need to create those secrets above with make use of faas-cli.\n\nLet's create our secrets\n```bash\n$ export WEBHOOK_SECRET=\"sup3rs3cr3t\"\n$ faas-cli secret create webhook-secret --from-literal $WEBHOOK_SECRET\n# Download the private key to your host\n$ faas-cli secret create private-key-secret --from-file \u003cpath_to_your_pem_file\u003e.pem\n```\n\nWe should create a secret in faasd, in order to do that we need to access the Gateway of faasd\n```bash\n$ export IP=$(multipass info faasd --format json| jq '.info.faasd.ipv4[0]' | tr -d '\\\"')\n# Let's capture the authentication password into a file for use with faas-cli\n$ ssh ubuntu@$IP \"sudo cat /var/lib/faasd/secrets/basic-auth-password\" \u003e basic-auth-password\n# Login from your laptop (the host)\n$ export OPENFAAS_URL=http://$IP:8080 \u0026\u0026 \\\ncat basic-auth-password | faas-cli login -s\n```\n\n### Connect your client to the inlets-pro server using inletsctl\nWe need to establish connection between our client, and the inlets-pro server in order to get events from there\n```bash\n$ export UPSTREAM=$IP # faasd gateway ip, we have already grap the URL above\n$ export PORTS=8080 # faasd gateway port\n$ export LICENSE=\"eyJhbGciOiJFUzI...\"\n\n# Notice that this command is the output of the \"inletsctl create\" command above\n$ inlets-pro client --url \"wss://XX.XXX.XXX.XX:8123/connect\" \\\n        --token \"$TOKEN\" \\\n        --license \"$LICENSE\" \\\n        --upstream $UPSTREAM \\\n        --ports $PORTS\n```\n### Test\nIn order to test it we need to install this app to selected repositories. Create a repository called \"test-issues-bot\", then install this app for it.\n![repository-access](./images/repository-access.png)\n\nThen, create an issue for the repository. You will see the message \n\u003e \"Hello, issue opened by: developer-guy\"\n\n![test-issue-bot](./images/test-issue-bot.png)\n![close-issue](./images/close-issue.png)\n\n### Cleanup\n```bash\n$ multipass delete faasd\n$ multipass purge\n$ inletsctl delete --provider ec2 --id \"YOUR_INSTANCE_ID\" --access-token $AWS_ACCESS_KEY --secret-key $AWS_SECRET_KEY --region eu-central-1\n```\n\n### Next steps\nYou can run this Bot on a Raspberry Pi, with faasd and TLS with inlets-pro and Caddy! Checkout this [README](./docs/faasd_on_pi.md) to know how.\n\nYaaay 🎉🎉🎉🎉🎉🎉🎉\n# References\n* https://blog.alexellis.io/deploy-serverless-faasd-with-cloud-init/\n* https://www.x-cellent.com/blog/automating-github-with-golang-building-your-own-github-bot/\n* https://blog.alexellis.io/share-work-using-inlets/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloper-guy%2Ffaasd-github-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloper-guy%2Ffaasd-github-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloper-guy%2Ffaasd-github-bot/lists"}