GitHub Actions
Push and manage artifacts in Harness Artifacts directly from GitHub Actions workflows, using the Setup Harness CLI action to install and authenticate.
You can push and manage artifacts in Harness Artifacts from any GitHub Actions workflow. The Setup Harness CLI action installs and authenticates the Harness CLI (hc) in your workflow runner. After the action runs, hc is on PATH and authenticated, so you can run any CLI command, including hc artifact push.
This integration is useful when your builds run in GitHub Actions and you want to store the resulting artifacts (Docker images, npm packages, Maven JARs, generic binaries, and others) in Harness Artifacts without switching to a different CI platform.
How it works
The integration follows a three-step pattern:
Install and authenticate. The
harness/setup-harness-cliaction downloads the Harness CLI, places it onPATH, and authenticates it with your Harness account using a personal access token (PAT).Push artifacts. After authentication, you call
hc artifact push(or any otherhccommand) in a subsequentrunstep to upload build outputs to a registry in Harness Artifacts.Automatic logout. The action logs the CLI out at the end of the job, even when the job fails, so the personal access token is not left on self-hosted runners.
Because the CLI handles authentication, you do not need to create a Harness connector or manage registry credentials manually in your workflow.
Before you begin
Harness account with Artifacts enabled. You need at least one registry created in Harness Artifacts. To create a registry, go to Create a registry.
Personal access token (PAT). Generate a PAT in your Harness account with permissions to push artifacts. To understand authentication, go to Authentication and identity tokens.
GitHub repository secrets. Store the following values as GitHub Actions secrets in your repository or organization settings:
HARNESS_URL: Your Harness API URL (for example,https://app.harness.io).HARNESS_ACCOUNT_ID: Your Harness account identifier.HARNESS_PAT_TOKEN: The personal access token you generated.
Set up the GitHub Actions workflow
Add the harness/setup-harness-cli action to your workflow file. The following example checks out the repository, installs and authenticates the Harness CLI, and pushes a generic artifact to a registry.
Scope the CLI to an organization and project
By default, the CLI operates at the account level. To scope the session to a specific Harness organization and project, set the optional org and project inputs on the action:
Push different package types
The hc artifact push command supports multiple package types. Replace generic with the subcommand that matches your artifact format.
To review the full list of supported push subcommands, go to CLI reference.
Security considerations
Store credentials as secrets. Never hard-code your PAT, account ID, or API URL in the workflow file. Use GitHub Actions secrets or environment-level secrets.
Use least-privilege tokens. Generate a PAT with only the permissions required to push to the target registry.
Automatic logout. The
setup-harness-cliaction runs a post-job cleanup step that logs the CLI out, even when the job fails. This prevents credentials from persisting on self-hosted runners between jobs.Pin the action version. Pin
harness/setup-harness-clito a specific version tag or commit SHA to avoid unexpected changes from upstream updates.
Troubleshooting
Next steps
To review inputs, outputs, version pinning, and additional examples for the GitHub Action, go to Setup Harness CLI.
To manage artifacts and registries from the CLI, go to CLI reference.
To configure client-side authentication for specific package types, go to the relevant page under Client setup.
To integrate Artifacts with Jenkins instead of GitHub Actions, go to Jenkins and Harness Artifacts.
Last updated
Was this helpful?