Codefresh Steps: Reusable Code for Common Operations
This page provides code you can use to perform common operations in the Codefresh CI/CD platform.
11K

Open or update a GitHub PR github-pr

Create, edit, or annotate a GitHub pull request.

arguments

  • BASE - The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository. Required for 'create' operation.
  • GITHUB_PR_NUMBER - The number of updated pull request. Required for open/close/update/merge operations
  • GITHUB_PR_OPERATION - Operation on pull request. Options - create, update, open, close, and merge. Default - create.
  • GITHUB_REPO_NAME - Name of repo
  • GITHUB_REPO_OWNER - Name of repo owner
  • GITHUB_TOKEN - Token for access to GitHub
  • HEAD - The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this - username:branch. Required for 'create' operation.
  • TITLE - The title of the pull request. Required for 'create' operation.
    create-github-pr:
  type: github-pr
  arguments:
    GITHUB_TOKEN: '${{GITHUB_TOKEN}}'
    GITHUB_REPO_OWNER: '${{GITHUB_REPO_OWNER}}'
    GITHUB_REPO_NAME: '${{GITHUB_REPO_NAME}}'
    HEAD: '${{CF_BRANCH}}'
    TITLE: 'Codefresh PR for ${{CF_BRANCH}}'
    BASE: master

  
    merge_github_pr:
  type: github-pr
  arguments:
    GITHUB_TOKEN: '${{GITHUB_TOKEN}}'
    GITHUB_REPO_OWNER: '${{CF_REPO_OWNER}}'
    GITHUB_REPO_NAME: '${{CF_REPO_NAME}}'
    GITHUB_PR_NUMBER: '${{CF_PULL_REQUEST_NUMBER}}'
    GITHUB_PR_OPERATION: merge
delete_merged_branch:
  image: 'alpine/git:latest'
  commands:
    - 'rm -rf ${{CF_REPO_NAME}}'
    - >-
      git clone
      https://codefresh:${{GITHUB_TOKEN}}@github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}.git
    - 'cd ${{CF_REPO_NAME}}'
    - 'git push origin --delete ${{CF_BRANCH}}'

  
github.com
Yaroslav Drachenko
May 17, 2021