You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -23,46 +23,113 @@ In this post we will walk through building a simple bot to label pull-requests.
23
23
24
24
## Pre-requisites
25
25
26
-
For the purposes of this guide we'll use a local install of Kubernetes, but any Kubernetes cluster could be used. The tutorial should take you less than 15-30 minutes to try.
26
+
For the purposes of this guide we'll create a local virtual machine and install faasd on it, but these instructions can be extended to use a Digital Ocean Droplet, or even a Raspberry Pi. The tutorial should take you less than 15-30 minutes to try.
27
27
28
-
A quick way to install all the tools you need is to use the [arkade](https://get-arkade.dev) cli tool.
28
+
### Create a Virtual Machine and install faasd
29
+
30
+
[Multipass](https://multipass.run) is a lightweight virtual machine runner, think docker-compose but for ubuntu virtual machines. We'll use this to get a virtual machine with faasd up and running quickly.
29
31
30
32
```bash
31
-
# Get arkade, and move it to $PATH
32
-
curl -sLS https://dl.get-arkade.dev | sh
33
-
sudo mv arkade /usr/local/bin/
33
+
# Install multipass
34
+
## On macOS you can install multipass with the brew command
35
+
brew install multipass
36
+
## or, on Linux, you can install using the snap command
Next we'll need to install Gitea it up and running. This example uses the bleeding edge nightly version, but for production use you may wish to use the current stable version of Gitea.
Finally after Gitea is installed, we'll need to verify the installation. To do this we will open up the Gitea interface in the browser and login into it.
124
+
125
+
In the install step we created an admin user with the username `gitea_admin` and password `TEMPOPENFAASPASSWORD`, we will take those and go to the login page at http://$VM_IP:3000/user/login
Once logged in, we will create a git repository so when we need to add webhooks to it later it will be ready. In the top navigation bar we can select the `+` dropdown, and click the "New Repository" link. When we get to the new repository page we will name the repo `test_repo` and check the "Initialize Repository" option, just to have an example repository for testing purposes.
130
+
131
+

132
+
66
133
## Build and deploy the Gitea bot function
67
134
68
135
For this guide we will be using golang for the Gitea bot, but you can use any language that you are comfortable working with.
@@ -256,28 +323,26 @@ With the function now built, now it is time to deploy the function. First you'll
256
323
GO111MODULE: on
257
324
secrets:
258
325
- webhook-secret # random string generated by you
259
-
- gitea-host # host of your gitea instance, ex. https://gitea.example.com/
260
-
- gitea-token # gitea api token generated from https://gitea.example.com/user/settings/applications
326
+
- gitea-host # host of your gitea instance, ex. http://$VM_IP:3000/
327
+
- gitea-token # gitea api token generated from http://$VM_IP:3000/user/settings/applications
faas-cli secret create gitea-host --from-literal "http://$VM_IP:3000/"# Use IP from setup
266
333
faas-cli secret create gitea-token --from-literal "GET FROM GITEA GUI"
267
334
268
335
faas-cli up -f lgtmbot.yml
269
336
270
337
```
271
338
272
-
Finally, we need to configure the repo in Gitea that you would like to manage with this function. This can be done by going to the webhooks settings of the repo (ex https://gitea.example.com/org/repo/settings/hooks), and creating a new Gitea webhook with the secret being the one you set above.
339
+
Finally, we need to configure the repo in Gitea that you would like to manage with this function. This can be done by going to the webhooks settings of the repo (ex http://$VM_IP:3000/gitea_admin/test_repo/settings/hooks), and creating a new Gitea webhook with the secret being the one you set above.
273
340
274
341

275
342
276
343
## Wrapping Up
277
344
278
-
Now that we’ve seen how to create a simple bot using OpenFaaS, from here we can build upon this base and make more complex actions. The next step could be transforming the [lockbot](https://www.openfaas.com/blog/schedule-your-functions/) from an earlier post to support Gitea as well, or even extending [Derek](https://github.com/alexellis/derek/) to support Gitea. The possibilities are endless. Eventually we could end up with a number of functions to rival the GitHub apps marketplace.
279
-
280
-
This post uses OpenFaaS, but you could use faasd to keep the installation requirements a minimum.
345
+
Now that we’ve seen how to create a simple bot using faasd, from here we can build upon this base and make more complex actions. The next step could be transforming the [lockbot](https://www.openfaas.com/blog/schedule-your-functions/) from an earlier post to support Gitea as well, or even extending [Derek](https://github.com/alexellis/derek/) to support Gitea. The possibilities are endless. Eventually we could end up with a number of functions to rival the GitHub apps marketplace.
0 commit comments