From d7a4f8b4f87c91568827eb543b27ae56a092f779 Mon Sep 17 00:00:00 2001 From: Steve Coffman Date: Mon, 19 Jun 2023 11:03:08 -0400 Subject: [PATCH] Update index.md for GITHUB_TOKEN and gh cli note See nektos/act/#1831 --- src/beginner/index.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/beginner/index.md b/src/beginner/index.md index e8750f3..2752145 100644 --- a/src/beginner/index.md +++ b/src/beginner/index.md @@ -112,8 +112,19 @@ When inserting sensitive data in your terminal, it might be saved as plain text ### `GITHUB_TOKEN` -GitHub Actions provides `secrets.GITHUB_TOKEN` and `github.token` automatically, on which many actions rely. This is possible to do so in `act`, if you use set it as a secret (`GITHUB_TOKEN=ghp_...`). -If your workflow fails with an error about `token`, it most likely requires `GITHUB_TOKEN` to be set up. +GitHub [automatically provides](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret) a `GITHUB_TOKEN` secret when running workflows inside GitHub. If your workflow fails with an error about `token`, it most likely requires `GITHUB_TOKEN` to be set up. +If your workflow depends on this token, you need to create a [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) and pass it to `act` as a secret: +```bash +act -s GITHUB_TOKEN=[insert token or leave blank and omit equals for secure input] +``` + +If [GitHub CLI](https://cli.github.com/) is installed, the [`gh auth token`](https://cli.github.com/manual/gh_auth_token) command can be used to autmatically pass the token to act + +```bash +act -s GITHUB_TOKEN="$(gh auth token)" +``` + +**WARNING**: `GITHUB_TOKEN` will be logged in shell history if not inserted through secure input or (depending on your shell config) the command is prefixed with a whitespace. ## `.env`/`.secrets` files structure @@ -263,4 +274,4 @@ Similarly if we just wanted to trigger this workflow for node 10 and macos-lates This will trigger the workflow to use the following matrix configurations only: - `os: macos-latest, node 10` -Note that using the `--matrix` flag you can't add new values (for e.g. running the above workflow for node 20). It will simply ignore it. Moreover, the `exclude` field in the workflow will take precedance over the `--matrix` flag (for e.g. running the above workflow for only macos-latest and node 4 will result in no matrix configuration being used) \ No newline at end of file +Note that using the `--matrix` flag you can't add new values (for e.g. running the above workflow for node 20). It will simply ignore it. Moreover, the `exclude` field in the workflow will take precedance over the `--matrix` flag (for e.g. running the above workflow for only macos-latest and node 4 will result in no matrix configuration being used)