Skip to content

Commit

Permalink
Add creds support, update mod metadata, update pipeline titles and na…
Browse files Browse the repository at this point in the history
…mes (#7)

Co-authored-by: khushboosharma <khushboo@turbot.com>
  • Loading branch information
vkumbha and khushboo9024 authored Dec 12, 2023
1 parent 0080e50 commit f1e0a25
Show file tree
Hide file tree
Showing 47 changed files with 530 additions and 413 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@

# Flowpipe variable files
*.fpvars

# Flowpipe mod dependencies and logs
.flowpipe
*.cache.json

# Flowpipe configuration files
*.fpc
87 changes: 50 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# GitHub Library Mod for Flowpipe
# GitHub Mod for Flowpipe

A collection of [Flowpipe](https://flowpipe.io) pipelines that can be used to:
- Create issues
- Close issues
- Share projects with groups
- And more!

![image](https://github.com/turbot/flowpipe-mod-github/blob/main/docs/images/flowpipe_test_run.png?raw=true)
GitHub pipeline library for [Flowpipe](https://flowpipe.io), enabling seamless integration of GitHub services into your workflows.

## Documentation

- **[Pipelines →](https://hub.flowpipe.io/mods/turbot/github/pipelines)**
- **[Triggers →](https://hub.flowpipe.io/mods/turbot/github/triggers)**

## Getting started
## Getting Started

### Requirements

Docker daemon must be installed and running. Please see [Install Docker Engine](https://docs.docker.com/engine/install/) for more information.

### Installation

Expand All @@ -31,29 +28,32 @@ git clone https://github.com/turbot/flowpipe-mod-github.git
cd flowpipe-mod-github
```

### Configuration
### Credentials

Configure your credentials:
By default, the following environment variables will be used for authentication:

```sh
cp flowpipe.pvars.example flowpipe.pvars
vi flowpipe.pvars
```
- `GITHUB_TOKEN`

It's recommended to configure credentials through [input variables](https://flowpipe.io/docs/using-flowpipe/mod-variables) by setting them in the `flowpipe.pvars` file.
You can also create `credential` resources in configuration files:

**Note:** Credentials can also be passed in each pipeline run with `--pipeline-args access_token=ghpat_Token123`.
```sh
vi ~/.flowpipe/config/github.fpc
```

Additional input variables may be defined in the mod's `variables.hcl` file that can be configured to better match your environment and requirements.
```hcl
credential "github" "default" {
token = "ghp_..."
}
```

Variables with defaults set do not need to be explicitly set, but it may be helpful to override them.
For more information on credentials in Flowpipe, please see [Managing Credentials](https://flowpipe.io/docs/run/credentials).

### Usage

Start the Flowpipe server to get started:
List pipelines:

```sh
flowpipe service start
flowpipe pipeline list
```

Run a pipeline:
Expand All @@ -62,33 +62,46 @@ Run a pipeline:
flowpipe pipeline run get_current_user
```

## Passing pipeline arguments
You can pass in pipeline arguments as well:

```sh
flowpipe pipeline run get_issue_by_number --arg 'issue_number=3997' --arg 'repository_owner=turbot' --arg 'repository_name=steampipe'
```

To pass values into pipeline [parameters](https://flowpipe.io/docs/using-flowpipe/pipeline-parameters), use the following syntax:
To use a specific `credential`, specify the `cred` pipeline argument:

```sh
flowpipe pipeline run list_projects --pipeline-arg membership=true
flowpipe pipeline run get_issue_by_number --arg 'issue_number=3997' --arg cred=github_profile
```

Multiple pipeline args can be passed in with separate `--pipeline-arg` flags.
For more examples on how you can run pipelines, please see [Run Pipelines](https://flowpipe.io/docs/run/pipelines).

For more information on passing arguments, please see [Pipeline Args](https://flowpipe.io/docs/using-flowpipe/pipeline-arguments).
### Configuration

## Contributing
To avoid entering the `repository_owner` and `repository_name` for each pipeline run, you can configure your default repository by setting the `repository_full_name` variable:

If you have an idea for additional controls or just want to help maintain and extend this mod ([or others](https://github.com/topics/flowpipe-mod)) we would love you to join the community and start contributing.
```sh
cp flowpipe.fpvars.example flowpipe.fpvars
vi flowpipe.fpvars
```

- **[Join #flowpipe in our Slack community ](https://flowpipe.io/community/join)**
```hcl
repository_full_name = "turbot/steampipe"
```

Please see the [contribution guidelines](https://github.com/turbot/flowpipe/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/turbot/flowpipe/blob/main/CODE_OF_CONDUCT.md).
When running a pipeline, you can override this default repository with `repository_owner` and `repository_name` pipeline arguments, e.g., `--arg repository_owner=turbot --arg repository_name=steampipe`.

Want to help but not sure where to start? Pick up one of the `help wanted` issues:
## Open Source & Contributing

- [Flowpipe](https://github.com/turbot/flowpipe/labels/help%20wanted)
- [GitHub Library Mod](https://github.com/turbot/flowpipe-mod-github/labels/help%20wanted)
This repository is published under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). Please see our [code of conduct](https://github.com/turbot/.github/blob/main/CODE_OF_CONDUCT.md). We look forward to collaborating with you!

[Flowpipe](https://flowpipe.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 cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our [Open Source FAQ](https://turbot.com/open-source).

## License
## Get Involved

This mod is licensed under the [Apache License 2.0](https://github.com/turbot/flowpipe-mod-github/blob/main/LICENSE).
**[Join #flowpipe on Slack →](https://flowpipe.io/community/join)**

Flowpipe is licensed under the [AGPLv3](https://github.com/turbot/flowpipe/blob/main/LICENSE).
Want to help but not sure where to start? Pick up one of the `help wanted` issues:

- [Flowpipe](https://github.com/turbot/flowpipe/labels/help%20wanted)
- [GitHub Mod](https://github.com/turbot/flowpipe-mod-github/labels/help%20wanted)
Binary file removed docs/images/flowpipe_test_run.png
Binary file not shown.
96 changes: 0 additions & 96 deletions docs/index.md

This file was deleted.

4 changes: 2 additions & 2 deletions flowpipe.fpvars.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
access_token ="ghpat-NotAReal_Token"
repository_full_name ="turbot/steampipe"
# Required
repository_full_name = "turbot/steampipe"
2 changes: 1 addition & 1 deletion locals.fp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Common descriptions
locals {
access_token_param_description = "The GitHub personal access token to authenticate to the GitHub APIs."
cred_param_description = "Name for credentials to use. If not provided, the default credentials will be used."
repository_owner_param_description = "The organization or user name."
repository_name_param_description = "The name of the repository."
}
Expand Down
13 changes: 6 additions & 7 deletions mod.fp
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# TODO: Add missing pipeline param descriptions
mod "github" {
title = "GitHub Library"
title = "GitHub"
description = "Run pipelines to supercharge your GitHub workflows using Flowpipe."
color = "#191717"
documentation = file("./docs/index.md")
icon = "/images/flowpipe/mods/turbot/github.svg"
categories = ["github", "library"]
documentation = file("./README.md")
icon = "/images/mods/turbot/github.svg"
categories = ["software development"]

opengraph {
title = "GitHub"
title = "GitHub Mod for Flowpipe"
description = "Run pipelines to supercharge your GitHub workflows using Flowpipe."
image = "/images/flowpipe/mods/turbot/github-social-graphic.png"
image = "/images/mods/turbot/github-social-graphic.png"
}
}
21 changes: 14 additions & 7 deletions pipelines/issue/add_issue_assignees.fp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# usage: flowpipe pipeline run add_issue_assignees --pipeline-arg "issue_number=151" --pipeline-arg 'assignee_ids=["MDQ6VXNlcjQwOTczODYz", "MDQ6VXNlcjM4MjE4NDE4"]'
pipeline "add_issue_assignees" {
title = "Add Issue Assignees"
description = "Add assignees to an issue."

param "access_token" {
tags = {
type = "featured"
}

param "cred" {
type = string
description = local.access_token_param_description
default = var.access_token
description = local.cred_param_description
default = "default"
}

param "repository_owner" {
Expand Down Expand Up @@ -34,7 +37,7 @@ pipeline "add_issue_assignees" {
step "pipeline" "get_issue_by_number" {
pipeline = pipeline.get_issue_by_number
args = {
access_token = param.access_token
cred = param.cred
repository_owner = param.repository_owner
repository_name = param.repository_name
issue_number = param.issue_number
Expand All @@ -47,7 +50,7 @@ pipeline "add_issue_assignees" {

request_headers = {
Content-Type = "application/json"
Authorization = "Bearer ${param.access_token}"
Authorization = "Bearer ${credential.github[param.cred].token}"
}

request_body = jsonencode({
Expand All @@ -56,7 +59,6 @@ pipeline "add_issue_assignees" {
addAssigneesToAssignable(
input: {assignableId: "${step.pipeline.get_issue_by_number.output.issue.id}", assigneeIds: ${jsonencode(param.assignee_ids)}}
) {
clientMutationId
assignable {
... on Issue {
id
Expand All @@ -77,6 +79,11 @@ pipeline "add_issue_assignees" {
}
EOQ
})

throw {
if = can(result.response_body.errors)
message = join(", ", flatten([for error in result.response_body.errors : error.message]))
}
}

output "issue" {
Expand Down
Loading

0 comments on commit f1e0a25

Please sign in to comment.