How to login to ArgoCD CLI non-interactive in CI like GitHub Actions?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
ArgoCD CLI requires authentication before you can manage applications. In interactive mode, argocd login prompts for credentials, but CI/CD pipelines like GitHub Actions run without human input. To log in non-interactively, use either an auth token with the --auth-token flag or pass --username/--password directly. The token-based approach is recommended because it avoids storing passwords and supports scoped permissions through ArgoCD API keys or project tokens.
Method 1: Auth Token (Recommended)
Generate an API token in ArgoCD and use it for headless login:
Use the token in CI:
The --grpc-web flag is needed when ArgoCD is behind an ingress that does not support HTTP/2 (gRPC). The --insecure flag skips TLS verification — use it only for self-signed certificates or in private networks.
Method 2: Username and Password
This works but requires storing the admin password as a secret, which is less secure than a scoped API token.
Method 3: ARGOCD_AUTH_TOKEN Environment Variable
Instead of passing --auth-token to every command, set the environment variable:
This is the cleanest approach for CI pipelines with multiple ArgoCD commands.
GitHub Actions Workflow
Store ARGOCD_TOKEN in GitHub repository secrets: Settings > Secrets and variables > Actions > New repository secret.
Creating a Dedicated CI Account
Create a separate ArgoCD account for CI instead of using admin:
Add the account:
Set RBAC permissions:
Generate the token:
This token can only sync and view applications — it cannot modify ArgoCD settings.
GitLab CI Example
Store ARGOCD_TOKEN in GitLab CI/CD variables (Settings > CI/CD > Variables, masked).
Using argocd app actions Without Full Login
For simple sync operations, you can skip the login step entirely and pass the server and token with each command:
This is useful for one-off commands but verbose for workflows with multiple commands.
Common Pitfalls
- Forgetting
--grpc-webbehind an ingress: ArgoCD uses gRPC (HTTP/2). Most ingress controllers (nginx, Traefik) do not pass gRPC through by default. Without--grpc-web, the CLI hangs or returns connection errors. Add--grpc-webto use HTTP/1.1 web transport. - Using
--insecurein production: This flag disables TLS certificate verification, making the connection vulnerable to man-in-the-middle attacks. Configure proper TLS certificates and omit--insecurein production environments. - Storing the admin password as a CI secret: The admin account has full access to ArgoCD. Create a dedicated CI account with minimal RBAC permissions and generate a scoped API token instead.
- Token expiration: ArgoCD tokens can be configured with an expiration time. If your CI pipeline fails with "token is expired," generate a new token or set a longer expiration:
argocd account generate-token --account ci-bot --expires-in 0(0 = no expiration). - Port mismatch: ArgoCD server listens on port 443 (HTTPS) by default. If your server is on a non-standard port (e.g., 8080), specify it:
argocd login argocd.example.com:8080. Omitting the port causes connection refused errors.
Summary
- Use
--auth-tokenwith a scoped API token for non-interactive CI login (most secure) - Set
ARGOCD_AUTH_TOKENas an environment variable to avoid passing the token to every command - Always add
--grpc-webwhen ArgoCD is behind a standard HTTP ingress - Create a dedicated CI account with minimal RBAC permissions instead of using admin
- Store tokens in CI platform secrets (GitHub Secrets, GitLab CI Variables)
- Use
argocd app wait --healthafter sync to ensure the deployment succeeds before the pipeline exits

