GitHub Action
Setup the GitHub CLI
π¨βπ» Install & configure the GitHub CLI (gh
) in your GitHub Actions runner
- 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
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 ofgh
to install. This can be an exact version like2.38.0
or a semver range like2.38
or2.x
. You can also specifylatest
to always use the latest version. The default islatest
. -
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 runninggh auth login
. This can be set to an empty string to skip the login step. By default this will use the tokengithub.token
. -
github-server-url
: The GitHub server URL to use when runninggh auth login
. Defaults to the currentgithub.server_url
.
-
gh-version
: The version ofgh
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 ifgh 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.