create_your_first.adoc 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. [#create-your-first-action]
  2. = Create your first action
  3. This page walks through adding your first action button — the step that turns a fresh OliveTin install into something you can actually click and use.
  4. When you are done, your dashboard will have a **Say Hello** button like this:
  5. image::action_buttons/create_your_first/hello-world.png[]
  6. == Before you start
  7. Make sure you have:
  8. * OliveTin **installed and running** — see the xref:install/intro.adoc[installation guide] if you have not done this yet
  9. * Access to your OliveTin **`config.yaml`** file — see xref:config.adoc#config[Configuration] for where OliveTin looks for this file on your platform
  10. * A text editor to change the file (any editor is fine)
  11. When OliveTin starts successfully, open the web interface in your browser (by default at `http://localhost:1337/`). You should see the OliveTin dashboard, even if it does not have any custom actions yet.
  12. == Step 1: Open `config.yaml`
  13. OliveTin is controlled entirely by `config.yaml`. On startup it looks for this file in several places — most commonly:
  14. * The directory you pass with `--configdir` (often the current working directory when you start OliveTin manually)
  15. * `/config/` inside containers
  16. * `/etc/OliveTin/` on Linux service installs
  17. If you are not sure which file your instance uses, check how you installed OliveTin (container, package, or manual) and open the `config.yaml` in that location.
  18. TIP: The xref:config.adoc[Configuration] page lists every search path and explains how live reload works when you save changes.
  19. == Step 2: Add an action
  20. Add an entry under `actions`. Each action needs at least a **title** (shown on the button) and a **shell** command to run:
  21. .`config.yaml`
  22. [source,yaml]
  23. ----
  24. actions:
  25. - title: Say Hello
  26. shell: echo "Hello World!"
  27. icon: smile
  28. onclick: execution-dialog
  29. ----
  30. * `title` — the label on the action button. It must be unique across all actions.
  31. * `shell` — the command OliveTin runs when you click the button. Here it prints `Hello World!` to the output.
  32. * `icon` — the glyph shown in the centre of the button. See xref:action_customization/icons.adoc[Icons] for other options.
  33. * `onclick: execution-dialog` — opens a dialog with the command output when the action runs, so you can see straight away that it worked. See xref:action_execution/ondemand.adoc[Execute on click] for other options.
  34. If your `config.yaml` already has other settings or actions, add this block alongside them. Only the `actions:` list is required for this example.
  35. == Step 3: Save the file
  36. Save `config.yaml`. OliveTin watches the file and **reloads configuration automatically** when it changes — you do not need to restart the service in most setups.
  37. Refresh the web page in your browser so the dashboard picks up the new action.
  38. NOTE: If the button does not appear after saving, check the OliveTin application logs for YAML syntax errors, then refresh again. A missing quote or incorrect indentation in `config.yaml` is the most common cause.
  39. == Step 4: Find your new button
  40. After reload, a new **Say Hello** button appears on the dashboard:
  41. image::action_buttons/create_your_first/hello-world.png[]
  42. Each action button shows the title at the bottom and the icon in the centre. The small icon in the top-right corner indicates that clicking opens an execution dialog. See xref:action_buttons/layout.adoc[Layout] for a breakdown of every part of the button.
  43. == Step 5: Run the action
  44. Click **Say Hello**. OliveTin runs `echo "Hello World!"` and opens the execution dialog with the output, timing, and exit code.
  45. If the dialog shows `Hello World!` and a successful exit code, your first action is working.
  46. == Step 6: View the logs
  47. Every execution is also recorded in the xref:logs/intro.adoc[Logs] section of the web interface. Open **Logs** in the navigation to browse past runs, search for executions, and open full output again later.
  48. == Important considerations
  49. * The action **title must be unique**. If two actions share the same title, only one button is shown.
  50. * The `shell` field runs your command through a shell. For more control (especially with arguments), use `exec` instead — see xref:action_execution/shellvsexec.adoc[Shell vs Exec].
  51. == What's Next?
  52. Now that you have a working action, try:
  53. * xref:action_buttons/layout.adoc[Layout] — understand the parts of an action button
  54. * xref:action_customization/intro.adoc[Customize your actions] — icons, timeouts, and other action properties
  55. * xref:args/intro.adoc[Add arguments to actions] — make actions interactive with user input
  56. * xref:action_examples/intro.adoc[Browse action examples] — real-world examples for common use cases
  57. * xref:action_execution/oncron.adoc[Schedule actions] — run actions automatically on a schedule
  58. * xref:action_execution/onwebhook.adoc[Trigger actions via webhooks] — integrate OliveTin with external systems
  59. * xref:dashboards/intro.adoc[Organize actions with dashboards] — create custom views to organize your actions