Sign inSign up

r6by/cf-github-pr-export

By r6by

Updated over 8 years ago

Codefresh image to export GitHub Pull Request ENV vars.

Image
0

1.8K

r6by/cf-github-pr-export repository overview

cf-github-pr-export

Codefresh image to export GitHub Pull Request ENV vars.

Test steps

Set up a GitHub repo for a Codefresh pipeline

In GitHub UI:

  1. Create and save a new GitHub Personal access token, setting the repo scope
  2. Create a new test repo
Set up a Codefresh pipeline

In Codefresh UI:

  1. Create a Codefresh account with a GitHub user

    Currently, it is possible to have only one git provider per account. You have to create a separate Codefresh account for each of your git providers.

  2. Add a (GitHub) repository

  3. Select only Pull request opened under Configuration > General Settings > Automated build > Trigger by

  4. Under Codefresh UI Environment Variables add GITHUB_TOKEN with the token you created above

  5. Under WORKFLOW toggle from Basic to YAML, and select Inline YAML

  6. In the inline YAML textarea, add this example YAML and click Save

    version: '1.0'
    steps:
    CFExport:
        title: Export CF_PR_ ENV vars
        image: r6by/cf-github-pr-export
    CFRead:
        title: Test read CF_PR_ ENV vars
        image: alpine:latest
        commands:
        - env | grep CF_PR_
    
Create a new pull request

In GitHub UI:

  1. Browse to your new test repo
  2. Click Create new file
  3. Name your file test (file can be empty), select Create a new branch for this commit and start a pull request, and click Propose new file
  4. On the next page, click Create pull request
Check the codefresh pipeline build logs

In Codefresh UI:

  1. Browse to Builds, and click View log next to the build that should have triggered from your new PR.
  2. The Test read CF ENV vars step should output:
    • CF_PR_NUMBER=1, where 1 is the number of your new PR
    • CF_PR_STATE=OPEN, if your PR is open. Otherwise CLOSED or MERGED
  3. Create another pull request, and ensure CF_PR_NUMBER matches the new PR number.
  4. Close, reopen, and merge the new PR, and ensure CF_PR_STATE matches each state.

Tag summary

Content type

Image

Digest

Size

3 MB

Last updated

over 8 years ago

docker pull r6by/cf-github-pr-export