👨💻 Install & configure the GitHub CLI (gh
) in your GitHub Actions runner
```yml - uses: actions4gh/setup-gh@v1 - run: gh issue create --body "$BODY" env: GH_REPO: ${{ github.repository }} BODY: Hello world! ``` |
👩💻 Installs any version of the GitHub CLI you want \ 🏃♂️ Works with self-hosted runners \ 🐳 Works great in container-based jobs
⚠️ This action is only useful if your runner doesn't already come with gh
.
The default GitHub Actions hosted runners come with gh
installed. You only
need this action to install gh
if you're using a Docker container for a job
or if you're using a self-hosted runner image that doesn't come with gh
installed.
Here's an example of a container
scenario where you might need to use this
action:
name: Test
on:
push:
branches: "main"
jobs:
test-alpine:
permissions:
issues: write
runs-on: ubuntu-latest
container: alpine:latest
steps:
- uses: actions/checkout@v4
- uses: actions4gh/setup-gh@v1
- run: gh issue create --body "$BODY"
env:
BODY: Hello world!
gh-version
: Which version of gh
to install. This can be an exact
version like 2.38.0
or a semver range like 2.38
or 2.x
. You can also
specify latest
to always use the latest version. The default is latest
.
cli-token
: The GitHub token to use when pulling versions from cli/cli.
By default this should cover all cases. You shouldn't have to touch this
setting.
token
: Token to use when running gh auth login
. This can be set to an
empty string to skip the login step. By default this will use the token
github.token
.
github-server-url
: The GitHub server URL to use when running
gh auth login
. Defaults to the current github.server_url
.
gh-version
: The version of gh
that was installed. This will be
something like '2.38.0' or similar.
auth
: A boolean indicating whether or not the user is authenticated.
This will be true if gh auth login
was run and false otherwise.
How do I test my changes?
Open a Draft Pull Request and some magic GitHub Actions will run to test the action.