Skip to content

Commit

Permalink
add initial doc files
Browse files Browse the repository at this point in the history
  • Loading branch information
karanpopat committed Aug 13, 2024
1 parent dfb98fc commit b662d47
Show file tree
Hide file tree
Showing 10 changed files with 353 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Trigger Vercel deploy (prod)

on:
push:
branches:
- main
workflow_dispatch:
jobs:
trigger-vercel-deploy:
runs-on: ubuntu-latest
steps:
- name: Trigger Vercel deploy
run: |
curl -X POST ${{ secrets.VERCEL_DEPLOY_LINK_PROD }}
21 changes: 21 additions & 0 deletions .github/workflows/trigger-tailpipe-io.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Trigger the preview build in tailpipe.io

on:
workflow_dispatch:

push:
branches-ignore:
- "main"

jobs:
update:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.G_PERSONAL_ACCESS_TOKEN }}
repository: turbot/tailpipe.io
event-type: build-preview
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "ref_name": "${{ github.ref_name }}"}'
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
![image](https://tailpipe.io/images/open_graph_preview.png)

<!-- # Tailpipe docs format & structure -->

Docs are written in Markdown format and are located in the `docs` folder. The entry-point document will contain front-matter with `slug: /`.

Each document requires the following frontmatter, adjust the values as per your requirement:

```yaml
id: learn
title: Learn Tailpipe
sidebar_label: Learn Tailpipe
```
We support up to 2 levels of docs, e.g.:
- `docs/foo`
- `docs/foo/bar`

For your docs to appear in the sidebar, you need to edit `docs/sidebar.json`. This is an array of sidebar entries, which are either stings matching the path of the required document, or a category to nest the docs down 1 level.

Any images required by docs must be placed in `/images/docs/...` and must be referenced by the tag `<img src="/images/docs/..." />`.

# Guidelines for contribution

<!-- Thank you for your interest in contributing to Tailpipe documentation! We greatly value feedback and contributions from our community. -->

Please read through this document before you submit any pull requests or issues. It will help us to collaborate more effectively.

## What to expect when you contribute

When you submit a pull request, our team is notified and will respond as quickly as we can. We'll do our best to work with you to ensure that your pull request adheres to our style and standards.

We look forward to receiving your pull requests for:

- Inaccuracies in the content
- Information gaps in the content that need more detail to be complete
- Grammatical errors or typos
- Suggested rewrites that improve clarity and reduce confusion

## How to contribute

To contribute, send us a pull request.

1. [Fork the repository](https://help.github.com/articles/fork-a-repo/).
2. In your fork, make your change in a branch that's based on this repo's **main** branch.
3. Commit the change to your fork, using a clear and descriptive commit message.
4. [Create a pull request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/)

Before you send us a pull request, please be sure that:

1. You're working from the latest source on the **main** branch.
2. You check [existing open](https://github.com/turbot/tailpipe-docs/pulls) pull requests to be sure that someone else hasn't already addressed the problem.
3. You [create an issue](https://github.com/turbot/tailpipe-docs/issues/new) before working on a contribution that will take a significant amount of your time.

For contributions that will take a significant amount of time, [open a new issue](https://github.com/turbot/tailpipe-docs/issues/new) to pitch your idea before you get started. Explain the problem and describe the content you want to see added to the documentation. We don't want you to spend a lot of time on a contribution that might be outside the scope of the documentation or that's already in progress.

## Finding contributions to work on

If you'd like to contribute, but don't have a project in mind, look at the [open issues](https://github.com/turbot/tailpipe-docs/issues/news) in this repository for some ideas.

## Open Source & Contributing

This repository is published under the [CC BY-NC-ND](https://creativecommons.org/licenses/by-nc-nd/4.0/) license. Please see our [code of conduct](https://github.com/turbot/.github/blob/main/CODE_OF_CONDUCT.md). Contributors must sign our [Contributor License Agreement](https://turbot.com/open-source#cla) as part of their first pull request. We look forward to collaborating with you!

[Tailpipe](https://tailpipe.io) is a product produced from this open source software, exclusively by [Turbot HQ, Inc](https://turbot.com). It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but they cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our [Open Source FAQ](https://turbot.com/open-source).
243 changes: 243 additions & 0 deletions docs/learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
---
id: learn
title: Learn Tailpipe
sidebar_label: Learn Tailpipe
slug: /
---

# Learn Tailpipe

Tailpipe allows you to create "pipelines as code" to define workflows and other tasks that run in a sequence.

## Creating your first pipeline

Getting started is easy! If you haven't already done so, [download and install Tailpipe](/downloads).

Tailpipe pipelines and triggers are packaged into [mods](/docs/build), and Tailpipe requires a mod to run. Let's create a new directory for our mod, and then run `tailpipe mod init` to initialize it:

```bash
mkdir learn_tailpipe
cd learn_tailpipe
tailpipe mod init
```

The `tailpipe mod init` command creates a file named `mod.fp` in the directory. This file contains a `mod` definition for our new mod:

```hcl
mod "local" {
title = "learn_tailpipe"
}
```

You can customize the [mod definition](/docs/tailpipe-hcl/mod) if you like, but the default is sufficient for our purposes.

Let's create our first pipeline.

Tailpipe mods are written in HCL. When Tailpipe runs, it will load the mod from the working directory and will read all files with the `.fp` extension from the directory and its subdirectories recursively. Create a file named `learn.fp` and add the following code:

```hcl
pipeline "learn_tailpipe" {
step "http" "get_ipv4" {
url = "https://api.ipify.org?format=json"
}
output "ip_address" {
value = step.http.get_ipv4.response_body.ip
}
}
```

A Tailpipe [pipeline](/docs/tailpipe-hcl/step/pipeline) is a sequence of steps to do work. This snippet creates a pipeline called `learn_tailpipe` that has a single [http step](/docs/tailpipe-hcl/step/http), and a single [output](/docs/tailpipe-hcl/step/pipeline#outputs).

Let's run it!

```bash
tailpipe pipeline run learn_tailpipe
```

![](/images/docs/learn/get-ipv4.png)

Tailpipe runs the pipeline and prints its outputs once it is complete.

When troubleshooting, it's often useful to view more information about the currently executing steps. You can use the `--verbose` flag to show this detailed information.

```bash
tailpipe pipeline run learn_tailpipe --verbose
```

![](/images/docs/learn/get-ipv4-verbose.png)

## Using mods

Tailpipe's modular design allows you to build pipelines from other pipelines. Let's install the `reallyfreegeoip` mod:

```bash
tailpipe mod install github.com/turbot/tailpipe-mod-reallyfreegeoip
```

```bash
Installed 1 mod:

local
└── github.com/turbot/[email protected]
```

The mod is installed into the `.tailpipe/mods` subdirectory, and a dependency is added to your `mod.fp`.

Now that the mod is installed, you should see its pipelines:

```bash
tailpipe pipeline list
```

```bash
MOD NAME DESCRIPTION
local learn_tailpipe
reallyfreegeoip reallyfreegeoip.pipeline.get_ip_geolocation Get geolocation data for an IPv4 or IPv6 address.
```

You can run pipelines from the dependency mod on the command line:

```bash
tailpipe pipeline run reallyfreegeoip.pipeline.get_ip_geolocation --arg ip_address=35.236.238.30
```

![](/images/docs/learn/reallyfreegeoip.png)

## Composing with pipelines

While running the dependency pipelines directly in the CLI is useful, the real power is the ability to compose pipelines from other pipelines. Let's add a [pipeline step](/docs/tailpipe-hcl/step/pipeline) to take our IP address and look up our geo-location information.

```hcl
pipeline "learn_tailpipe" {
step "http" "get_ipv4" {
url = "https://api.ipify.org?format=json"
}
step "pipeline" "get_geo" {
pipeline = reallyfreegeoip.pipeline.get_ip_geolocation
args = {
ip_address = step.http.get_ipv4.response_body.ip
}
}
output "ip_address" {
value = step.http.get_ipv4.response_body.ip
}
output "latitude" {
value = step.pipeline.get_geo.output.geolocation.latitude
}
output "longitude" {
value = step.pipeline.get_geo.output.geolocation.longitude
}
}
```

Notice that we used the IP address from the first step (`step.http.get_ipv4.response_body.ip`) as an argument to the second step. Tailpipe automatically detects this dependency and runs the steps in the correct order!

Let's add a couple more steps to get the weather forecast for our location.

```hcl
pipeline "learn_tailpipe" {
step "http" "get_ipv4" {
url = "https://api.ipify.org?format=json"
}
step "pipeline" "get_geo" {
pipeline = reallyfreegeoip.pipeline.get_ip_geolocation
args = {
ip_address = step.http.get_ipv4.response_body.ip
}
}
step "http" "get_weather" {
url = join("", [
"https://api.open-meteo.com/v1/forecast",
"?latitude=${step.pipeline.get_geo.output.geolocation.latitude}",
"&longitude=${step.pipeline.get_geo.output.geolocation.longitude}",
"&current=temperature",
"&forecast_days=1",
"&daily=temperature_2m_min,temperature_2m_max,precipitation_probability_mean",
"&temperature_unit=${step.pipeline.get_geo.output.geolocation.country_code == "US" ? "fahrenheit" : "celsius"}"
])
}
step "transform" "friendly_forecast" {
value = join("", [
"It is currently ",
step.http.get_weather.response_body.current.temperature,
step.http.get_weather.response_body.current_units.temperature,
", with a high of ",
step.http.get_weather.response_body.daily.temperature_2m_max[0],
step.http.get_weather.response_body.daily_units.temperature_2m_max,
" and a low of ",
step.http.get_weather.response_body.daily.temperature_2m_min[0],
step.http.get_weather.response_body.daily_units.temperature_2m_min,
". There is a ",
step.http.get_weather.response_body.daily.precipitation_probability_mean[0],
step.http.get_weather.response_body.daily_units.precipitation_probability_mean,
" chance of precipitation."
])
}
output "ip_address" {
value = step.http.get_ipv4.response_body.ip
}
output "latitude" {
value = step.pipeline.get_geo.output.geolocation.latitude
}
output "longitude" {
value = step.pipeline.get_geo.output.geolocation.longitude
}
output "forecast" {
value = step.transform.friendly_forecast.value
}
}
```

![](/images/docs/learn/weather-report.png)



## Send a message

Now we have a pipeline that can get the local forecast - let's send it somewhere! The [message step](/docs/tailpipe-hcl/step/message) provides a mechanism for sending messages via multiple communication channels, such as Slack and Email.

Add this step to the `learn_tailpipe` pipeline.

```hcl
step "message" "send_forecast" {
notifier = notifier.default
subject = "Todays Forecast"
text = step.transform.friendly_forecast.value
}
```

And run the pipeline again.

```bash
tailpipe pipeline run learn_tailpipe
```

You should see the message printed to the console when you run the pipeline.

Console messages and inputs are useful, but Tailpipe can also route these input requests, approvals and notifications to external systems like Slack, MS Teams, and Email!

Tailpipe [Integrations](/docs/reference/config-files/integration) allow you to interface with external systems. [Notifiers](/docs/reference/config-files/notifier) allow you to route [message](/docs/tailpipe-hcl/step/message) and [input](/docs/build/input) steps to one or more integrations. Integrations are only loaded in [server-mode](/docs/run/server).


Tailpipe server creates a default [`http` integration](/docs/reference/config-files/integration/http) as well as a [default notifier](/docs/reference/config-files/notifier#default-notifier) that routes to it, but you can send it via [Email](/docs/reference/config-files/integration/email), [Slack](/docs/reference/config-files/integration/slack) or [Microsoft Teams](/docs/reference/config-files/integration/msteams) without modifying the pipeline code. Just create the appropriate [integrations](/docs/reference/config-files/integration), add them to the [default notifier](/docs/reference/config-files/notifier#default-notifier), and run the pipeline again from a server instance!

```bash
tailpipe server &
tailpipe pipeline run learn_tailpipe --host local
```

![](/images/docs/learn/slack-weather-report.png)

9 changes: 9 additions & 0 deletions docs/sidebar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"type": "category",
"id": "learn",
"label": "Learn Tailpipe",
"link": "learn",
"items": []
}
]
Binary file added images/learn/get-ipv4-verbose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/learn/get-ipv4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/learn/reallyfreegeoip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/learn/slack-weather-report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/learn/weather-report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b662d47

Please sign in to comment.