Skip to content

Commit

Permalink
Add helper script to set docker env (#35)
Browse files Browse the repository at this point in the history
* Add helper script to set docker environment

* Add README
  • Loading branch information
at-wat authored Aug 3, 2020
1 parent 291036e commit 57666ed
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ $ curl -sL https://raw.githubusercontent.com/at-wat/gh-pr-comment/master/install

## Required environment variables

### Travis-CI
To run gh-pr-comment inside docker container, required environemnt variables can be automatically specified by the following script.
```shell
$ docker run [your options...] \
$(bash <(curl -s https://raw.githubusercontent.com/at-wat/gh-pr-comment/master/env.sh)) \
image commands...
```

### General
- ***GITHUB\_TOKEN*** (or ***TRAVIS\_BOT\_GITHUB\_TOKEN***): token with comment write permission

### Optional
- ***GITHUB\_API\_URL\_BASE***: specify GitHub Enterprise or any custom endpoint URL

### Travis-CI
- ***TRAVIS***: true
- ***TRAVIS\_PULL\_REQUEST\_SLUG***: owner/repos
- ***TRAVIS\_PULL\_REQUEST***: pull request number
- ***TRAVIS\_BOT\_GITHUB\_TOKEN*** or ***GITHUB\_TOKEN***: token with comment write permission
25 changes: 25 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

# Output list of docker run options to pass required environment variables.

if [ "${TRAVIS}" = "true" ]
then
echo "-e TRAVIS"
echo "-e TRAVIS_PULL_REQUEST"
echo "-e TRAVIS_PULL_REQUEST_SLUG"
fi

if [ -n "${GITHUB_API_URL_BASE}" ]
then
echo "-e GITHUB_API_URL_BASE"
fi

if [ -n "${GITHUB_TOKEN}" ]
then
echo "-e GITHUB_TOKEN"
fi

if [ -n "${TRAVIS_BOT_GITHUB_TOKEN}" ]
then
echo "-e TRAVIS_BOT_GITHUB_TOKEN"
fi

0 comments on commit 57666ed

Please sign in to comment.