Skip to content

kostua16/setup-gh

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

145 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Setup the GitHub CLI (Fork by @kostua16)

πŸ‘¨β€πŸ’» Install & configure the GitHub CLI (gh) in your GitHub Actions runner (Fork by @kostua16)

- uses: kostua16/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

Usage

GitHub Actions GitHub

⚠️ 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: kostua16/setup-gh@v1
      - run: gh issue create --body "$BODY"
        env:
          BODY: Hello world!

Inputs

  • 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.

  • switch-account: Whether to switch later gh commands to the provided token, even when another account is already authenticated. This also exports the provided token as GH_TOKEN and a fresh isolated GH_CONFIG_DIR for later workflow steps. Each switch-account: true invocation creates its own config directory. The default is false.

  • skip-matching-version: If false, installation is skipped whenever any gh is already on PATH. If true, installation is skipped only when the installed version matches gh-version. The default is false.

  • github-server-url: The GitHub server URL to use when running gh auth login. Defaults to the current github.server_url.

Outputs

  • gh-version: The available version of gh. 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 a token was provided and authentication is available.

  • gh-config-dir: The GitHub CLI config directory used by this action.

Development

Node.js

How do I test my changes?

Open a Draft Pull Request and some magic GitHub Actions will run to test the action.

About

πŸ‘¨β€πŸ’» Install & configure the GitHub CLI (gh) in your GitHub Actions runner

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%