-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from turbot/release/v0.2
Release v0.2.0
- Loading branch information
Showing
6 changed files
with
222 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## v0.2.0 [2024-02-08] | ||
|
||
_What's new?_ | ||
|
||
- Added `create_branch`, `delete_branch` and `get_branch` pipelines. ([#10](https://github.com/turbot/flowpipe-mod-github/pull/10)) | ||
|
||
## v0.1.0 [2023-12-13] | ||
|
||
_What's new?_ | ||
|
||
- Added 35+ pipelines to make it easy to connect your issues, pull requests, repositories and more. For usage information and a full list of pipelines, please see [GitHub Mod for Flowpipe](https://hub.flowpipe.io/mods/turbot/github). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
pipeline "create_branch" { | ||
title = "Create Branch" | ||
description = "Creates a new branch in a specified repository." | ||
|
||
param "cred" { | ||
type = string | ||
default = "default" | ||
description = local.cred_param_description | ||
} | ||
|
||
param "repository_owner" { | ||
type = string | ||
description = local.repository_owner_param_description | ||
} | ||
|
||
param "repository_name" { | ||
type = string | ||
description = local.repository_name_param_description | ||
} | ||
|
||
param "branch_name" { | ||
type = string | ||
description = "The name of the new branch." | ||
} | ||
|
||
param "source_branch" { | ||
type = string | ||
description = "The name of the source branch to branch off. Defaults to the default branch of the repository." | ||
default = "main" | ||
} | ||
|
||
step "http" "get_latest_commit_sha" { | ||
method = "get" | ||
url = "https://api.github.com/repos/${param.repository_owner}/${param.repository_name}/branches/${param.source_branch}" | ||
request_headers = { | ||
Authorization = "Bearer ${credential.github[param.cred].token}" | ||
} | ||
} | ||
|
||
step "http" "create_branch" { | ||
method = "post" | ||
url = "https://api.github.com/repos/${param.repository_owner}/${param.repository_name}/git/refs" | ||
request_headers = { | ||
Content-Type = "application/json" | ||
Authorization = "Bearer ${credential.github[param.cred].token}" | ||
} | ||
|
||
request_body = jsonencode({ | ||
ref = "refs/heads/${param.branch_name}", | ||
sha = "${step.http.get_latest_commit_sha.response_body.commit.sha}" | ||
}) | ||
|
||
throw { | ||
if = can(result.response_body.errors) | ||
message = join(", ", flatten([for error in result.response_body.errors : error.message])) | ||
} | ||
} | ||
|
||
output "branch" { | ||
value = step.http.create_branch | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
pipeline "delete_branch" { | ||
title = "Delete Branch" | ||
description = "Deletes a branch in a specified repository." | ||
|
||
param "cred" { | ||
type = string | ||
default = "default" | ||
description = local.cred_param_description | ||
} | ||
|
||
param "repository_owner" { | ||
type = string | ||
description = local.repository_owner_param_description | ||
} | ||
|
||
param "repository_name" { | ||
type = string | ||
description = local.repository_name_param_description | ||
} | ||
|
||
param "branch_name" { | ||
type = string | ||
description = "The name of the branch to delete." | ||
} | ||
|
||
step "http" "delete_branch" { | ||
method = "delete" | ||
url = "https://api.github.com/repos/${param.repository_owner}/${param.repository_name}/git/refs/heads/${param.branch_name}" | ||
request_headers = { | ||
Authorization = "Bearer ${credential.github[param.cred].token}" | ||
} | ||
|
||
throw { | ||
if = can(result.response_body.errors) | ||
message = join(", ", flatten([for error in result.response_body.errors : error.message])) | ||
} | ||
} | ||
|
||
output "branch" { | ||
value = step.http.delete_branch | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
pipeline "get_branch" { | ||
title = "Get branch" | ||
description = "Get a branch in a specified repository." | ||
|
||
param "cred" { | ||
type = string | ||
default = "default" | ||
} | ||
|
||
param "repository_owner" { | ||
type = string | ||
description = local.repository_owner_param_description | ||
} | ||
|
||
param "repository_name" { | ||
type = string | ||
description = local.repository_name_param_description | ||
} | ||
|
||
param "branch_name" { | ||
type = string | ||
description = "The name of the branch to check." | ||
} | ||
|
||
step "http" "get_branch" { | ||
method = "get" | ||
url = "https://api.github.com/repos/${param.repository_owner}/${param.repository_name}/branches/${param.branch_name}" | ||
request_headers = { | ||
Authorization = "Bearer ${credential.github[param.cred].token}" | ||
} | ||
error { | ||
ignore = true | ||
} | ||
} | ||
|
||
output "branch" { | ||
value = step.http.get_branch | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
pipeline "test_branch_operations" { | ||
title = "Test Branch Operations" | ||
description = "Test the create_branch, get_branch, and delete_branch pipelines." | ||
|
||
tags = { | ||
type = "test" | ||
} | ||
|
||
param "cred" { | ||
type = string | ||
description = local.cred_param_description | ||
default = "default" | ||
} | ||
|
||
param "repository_owner" { | ||
type = string | ||
} | ||
|
||
param "repository_name" { | ||
type = string | ||
} | ||
|
||
param "branch_name" { | ||
type = string | ||
} | ||
|
||
step "transform" "args" { | ||
value = { | ||
cred = param.cred | ||
repository_owner = param.repository_owner | ||
repository_name = param.repository_name | ||
branch_name = param.branch_name | ||
} | ||
} | ||
|
||
step "pipeline" "create_branch" { | ||
pipeline = pipeline.create_branch | ||
args = step.transform.args.value | ||
} | ||
|
||
step "pipeline" "get_branch" { | ||
depends_on = [step.pipeline.create_branch] | ||
pipeline = pipeline.get_branch | ||
args = step.transform.args.value | ||
} | ||
|
||
step "pipeline" "delete_branch" { | ||
depends_on = [step.pipeline.get_branch] | ||
pipeline = pipeline.delete_branch | ||
args = step.transform.args.value | ||
} | ||
|
||
output "check_create_branch" { | ||
value = step.pipeline.create_branch.output.branch.status_code == 201 ? "pass" : "fail" | ||
} | ||
|
||
output "check_get_branch" { | ||
value = step.pipeline.get_branch.output.branch.status_code == 200 ? "pass" : "fail" | ||
} | ||
|
||
output "check_delete_branch" { | ||
value = step.pipeline.delete_branch.output.branch.status_code == 204 ? "pass" : "fail" | ||
} | ||
|
||
} |