From 75af7eb53b8de4d401cae5b3b9cb9a875567aff8 Mon Sep 17 00:00:00 2001 From: Thomas Schoffelen Date: Mon, 31 Dec 2018 19:55:46 +0100 Subject: [PATCH] Added info about the differences with GitHub, and allow passing through GITHUB_TOKEN --- README.md | 14 +++++++++----- lib/utils.js | 4 ++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8b4d844..a81e116 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Options: -h, --help output usage information ``` -### Passing secrets +### Supplying values for secrets You can set the value of [secrets](https://developer.github.com/actions/creating-workflows/storing-secrets/) defined in your workflow by passing them as environment variables, e.g.: @@ -38,6 +38,14 @@ You can set the value of [secrets](https://developer.github.com/actions/creating MY_SECRET_TOKEN=yo-mamma gha ``` +### Differences with GitHub Actions + +Although this way of locally running GitHub Actions is very close to how they +will work when actually running them on GitHub, there are a few small differences: + +* In the GitHub environment, the `GITHUB_TOKEN` is passed to all actions by default. This is not the case in the local environment, but can be achieved by creating a [personal token](https://github.com/settings/tokens/new?scopes=repo&description=GHA) and supplying it as a secret (see above). +* The `/github/home` volume in the container is tied to your local directory `/tmp/gh-home`. In GitHub, this directory is container-specific, whereas this script shares it between all containers. + ## Development @@ -50,7 +58,3 @@ to add: - [ ] Add support for local Docker images: [`./path/to/dir`](https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#using-a-dockerfile-image-in-an-action) - [ ] Add support for Docker Hub images: [`docker://{image}:{tag}`](https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#using-a-dockerfile-image-in-an-action) - [ ] Add support for custom hosted Docker images: [`docker://{host}/{image}:{tag}`](https://developer.github.com/actions/creating-workflows/workflow-configuration-options/#using-a-dockerfile-image-in-an-action) - -Some improvements are also possible in other areas: - -- [ ] Add support for default [`GITHUB_TOKEN`](https://developer.github.com/actions/creating-workflows/storing-secrets/#github-token-secret) env var diff --git a/lib/utils.js b/lib/utils.js index bf02954..4bba765 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -130,6 +130,10 @@ const runAction = (actionTitle, actions, event, verbose) => { }) } + if ('GITHUB_TOKEN' in process.env && !('GITHUB_TOKEN' in action.env)) { + action.env.GITHUB_TOKEN = process.env.GITHUB_TOKEN + } + const uses = action.uses const imageName = resolveRunner(uses, verbose) let args = []