I always saw the lack of Custom Actions as the biggest downside of Buddy. There was an action Custom Build, but it didn’t provide us with any UI options, and it was pretty tedious to share and keep updated.
Luckily, Custom Actions change all of this. From now, you can:
How to store Custom Actions
There are three ways to do so:
Each is useful in some cases. A separate repository for all your actions is excellent when you work in a company and want to have all your actions in one place.
If you are considering an Open Source approach, having separate actions in separate repositories seems best.
But, if you want to create related actions with a project, then adding them to that project’s repo is the best solution.
For more information, check out the official Buddy documentation.
How to create a Custom Action
Again, you have a choice. You can either create everything manually based on the documentation or use this small tool I made.
If you decide to use Buddy Custom Action CLI, you only need to run npx buddy-custom-action@latest and answer a few questions. When you are done, you should have a ready-to-use boilerplate.
Example #1 - No deployment on Friday action
Some time ago, I created this simple action that prevents deploying on Fridays. Let’s try to convert it into a Custom Action.
First, I used the npx buddy-custom-action@latest. I only provided it with a name and a short description, and I said yes to creating an execute commands section.
This is my boilerplate. Of course, right now, it won’t do anything. It’s time to add the missing command itself:
Is this all? No - we should also add an icon and name it action.png
Now we are done. It was simple. Now it’s time to create something more complicated.
You can download the code from this repository.
Example #2 - API Parser
This time, we’ll create something more complicated. This action will get data from a given API then it will be parsed with jq and in the end, we will pass the result to another action.
Again, let’s get started with running the npx buddy-custom-action@latest. We’ll also need inputs and outputs this time.
Let’s start with the inputs. Inputs are the fields that you can populate with some data. In our case, we will need the following:
I will use the Star Wars API and filter out the character’s name.
Now it’s time to add the exectute_commands:
It works - we will get Luke Skywalker as a result. But, while it works, this action is a bit useless. It would be much better to pass the result to other actions. Let’s do it, then.
This is when outputs come in handy:
This will result in a tiny change in how your action looks:
Now, we have to change the execute_commends too:
From this point, we can use the result variable in other actions.
The whole action should look like this:
You can download the code from this repository.
What else can you do?
The sky is the limit here. I see Custom Actions as one of the most groundbreaking features in Buddy, and it gives everyone the potential to create and share their own actions. We don’t have to wait until developers have time to implement something - now, we can do it independently.
I can’t wait to see what actions you will create.
Share your thoughts