1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-12-02 06:52:15 +00:00
catalog/github
Divyansh42 42d6a5678e Add task to label github pull request or an issue
This task can be used to add labels to a github pull request or an issue.

Signed-off-by: Divyansh42 <diagrawa@redhat.com>
2020-06-04 09:30:53 +01:00
..
add-labels Add task to label github pull request or an issue 2020-06-04 09:30:53 +01:00
create-github-release Add Github Release task 2020-05-13 14:46:03 +01:00
add_comment.yaml Github Enterprise support for github tasks 2020-04-10 07:51:02 +01:00
close_issue.yaml Github Enterprise support for github tasks 2020-04-10 07:51:02 +01:00
README.md Improve Readme.md 2020-06-02 09:03:51 +01:00
set_status.yaml Github Enterprise support for github tasks 2020-04-10 07:51:02 +01:00

GitHub

A collection of tasks to help working with the GitHub API.

GitHub token

Most tasks would expect to have a secret set in the kubernetes secret github with a GitHub token in the key token, you can easily create it on the command line with kubectl like this :

kubectl create secret generic github --from-literal token="MY_TOKEN"

Set Status on a Commit/PR

The github-set-status task allows external services to mark GtiHUB commits with an error, failure, pending, or success state, which is then reflected in pull requests involving those commits.

Statuses include as well a description and a target_url, to give the user informations about the CI statuses or a direct link to the full log.

Install the Task

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/v1beta1/github/set_status.yaml

Parameters

  • REPO_FULL_NAME:: The GitHub repository full name, e.g: tektoncd/catalog
  • GITHUB_HOST_URL:: The GitHub host domain default: api.github.com
  • API_PATH_PREFIX:: The GitHub Enterprise has a prefix for the API path. e.g: /api/v3
  • SHA:: The commit SHA to set the status for e.g: tektoncd/catalog
  • TARGET_URL:: The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status. For example you can link to a dashboard URL so users can follow a Pipeline/Task run.
  • DESCRIPTION:: A short description of the status. e.g: Building your PR
  • CONTEXT: The GitHub context, A string label to differentiate this status from the status of other systems. e.g: continuous-integration/tekton
  • STATE: The state of the status. Can be one of the following error, failure, pending, or success.

Usage

This TaskRun sets a commit on GitHub to pending getting tested by the CI.

---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  labels:
    tekton.dev/task: github-set-status
  name: github-set-status-run-on-commit-bd93
spec:
  taskRef:
    kind: Task
    name: github-set-status
  params:
    - name: REPO_FULL_NAME
      value: tektoncd/catalog
     - name: SHA
      value: bd93869b489258cef567ccf85e7ef6bc0d6949ea
    - name: DESCRIPTION
      value: "Build has started"
    - name: STATE
      value: pending
    - name: TARGET_URL
      value: https://tekon/dashboard/taskrun/log

Add a comment to an issue or a pull request

The github-add-comment task let you add a comment to a pull request or an issue.

Install the Task

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/v1beta1/github/add_comment.yaml

Parameters

  • GITHUB_HOST_URL:: The GitHub host domain (default: api.github.com)
  • API_PATH_PREFIX:: The GitHub Enterprise has a prefix for the API path. e.g: /api/v3
  • REQUEST_URL:: The GitHub pull request or issue url, e.g: https://github.com/tektoncd/catalog/issues/46
  • COMMENT:: The actual comment to add e.g: don't forget to eat your vegetables before commiting..

Usage

This TaskRun add a comment to an issue.

---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  labels:
    tekton.dev/task: github-add-comment
  name: github-add-comment-to-pr-22
spec:
  taskRef:
    kind: Task
    name: github-add-comment
  params:
    - name: REQUEST_URL
      value: https://github.com/chmouel/scratchpad/pull/46
    - name: COMMENT
      value: |
          The cat went here and there
          And the moon spun round like a top,
          And the nearest kin of the moon,
          The creeping cat, looked up.
          Black Minnaloushe stared at the moon,
          For, wander and wail as he would,
          The pure cold light in the sky
          Troubled his animal blood.          

Close an issue or a pull request

The github-close-issue task let you close a pull request or an issue.

Install the Task

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/v1beta1/github/close_issue.yaml

Parameters

  • GITHUB_HOST_URL:: The GitHub host domain (default: api.github.com)
  • API_PATH_PREFIX:: The GitHub Enterprise has a prefix for the API path. e.g: /api/v3
  • REQUEST_URL:: The GitHub pull request or issue url, (e.g: https://github.com/tektoncd/catalog/issues/46)

Usage

This TaskRun close an issue on a task.

---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  labels:
    tekton.dev/task: github-close-issue
  name: github-close-issue-to-pr-46
spec:
  taskRef:
    kind: Task
    name: github-close-issue
  params:
    - name: REQUEST_URL
      value: https://github.com/chmouel/scratchpad/pull/46