Coming from gh
The commands that do what GitHub's gh does for a repository, and where they behave differently.
The dcloud takes the commands of gh with the same words and the same flags. Type
dcloud git where you typed gh, or dcloud ci for runs, workflows, secrets and variables.
Inside a clone, the repository and the branch are read from the directory, as in gh.
The command map
| gh | dcloud | Commands |
|---|---|---|
gh repo |
dcloud git repo |
list, view, create, clone, fork, sync, edit, delete, archive, unarchive, deploy-key, read-dir, read-file |
gh pr |
dcloud git pr |
list, view, create, checkout, diff, checks, review, comment, merge, ready, close, reopen, edit, update-branch, status |
gh issue |
dcloud git issue |
list, view, create, edit, close, reopen, comment, status |
gh release |
dcloud git release |
list, view, create, edit, delete, delete-asset, download, upload |
gh label |
dcloud git label |
list, create, edit, delete, clone |
gh search |
dcloud git search |
repos, issues, prs |
gh browse |
dcloud git browse |
|
gh ssh-key |
dcloud git ssh-key |
list, add, delete |
gh run |
dcloud ci run |
list, view, watch, rerun, cancel, download |
gh workflow |
dcloud ci workflow |
list, view, run |
gh secret |
dcloud ci secret |
list, set, delete |
gh variable |
dcloud ci variable |
list, get, set, delete |
gh api |
dcloud api |
|
gh auth login, logout, status, token |
dcloud auth |
the same words |
gh auth switch |
dcloud auth use |
|
gh auth setup-git |
dcloud auth setup-git |
|
gh completion |
dcloud completion |
-s bash, zsh, fish or powershell |
dcloud git run, dcloud git workflow, dcloud git secret and dcloud git variable are the
same commands as the dcloud ci ones. dcloud git pr merge --help lists the flags of a command
and names the gh command it stands for.
The commands named after the API (dcloud git pulls merge, with the repository id as an
argument) stay as they are; the pages of this guide use them.
Which repository a command works on
A command takes the repository from the first of these that is set:
-Rmy-org/my-repo (or--repo), where my-org is your organization's slug.- The environment variable
DCLOUD_REPO. - The git remote of the current directory: the remote the current branch tracks, else
origin.
There is no repo set-default. When several remotes point at Deutsche Cloud repositories and none
of the above decides, the command exits with code 2 and lists them. repo delete and
repo archive take --yes only with a repository you named; for one read from the directory
they show its name and ask.
A day of work
dcloud auth login
dcloud auth setup-git
dcloud git repo clone my-org/my-repo
cd my-repo
git switch -c fix-greeting
git commit -am "Fix the greeting"
git push -u origin fix-greeting
dcloud git pr create --fill
dcloud git pr checks --watch
dcloud ci run list --branch fix-greeting --status failure
dcloud ci run view 42 --log-failed
dcloud git pr review --approve --body "Reads well."
dcloud git pr merge --squash --delete-branch
dcloud git release create v1.0.0 dist/my-app.tar.gz --title "First release" --notes "The greeting is fixed."
dcloud ci run download 43 --name my-artifact --dir outReplace 42 and 43 with a run number from dcloud ci run list.
dcloud auth setup-git makes git use your dcloud sign-in for HTTPS, so cloning and pushing need
no access token of their own.
Scripts: JSON, jq and exit codes
--jsontakes a list of fields, by the nameghuses or by the name the API uses, and answers each under the name you asked for.--jsonwithout a list prints every field.- A field
ghhas and Deutsche Cloud has nothing for, for example a pull request'smergeStateStatusor a repository'sforkCount, is refused with exit code 2 and the list of the fields there are.--helpof a command lists them too. -q(or--jq) filters the JSON with a jq expression; without--jsonit filters every field. The expression runs in jq 1.8, andenvin it is your environment.- When the output is not a terminal, a list is tab-separated lines without a header.
- A value under a name the API also has is the API's: a pull request's
stateisopen,mergedorclosed, and a run'sstatusissucceeded, notcompletedwith aconclusion. A field onlyghhas holds whatghwrites, for examplereviewDecision: "APPROVED".
dcloud git pr list --state open --json number,title,headRefName
dcloud git pr view --json reviewDecision -q .reviewDecision
dcloud ci run list --limit 1 --json databaseId -q '.[0].databaseId'| Exit code | When |
|---|---|
| 0 | It worked; for pr checks, every check passed |
| 1 | A check failed (pr checks), the run failed (run watch --exit-status, run view --exit-status), or another error |
| 2 | The command line is wrong (gh: 1) |
| 3 | Not signed in (gh: 4) |
| 4 | Signed in, and a policy refuses the action (gh: 1) |
| 5 | No such repository, pull request, run or release (gh: 1) |
| 8 | pr checks: checks are still pending |
The API escape hatch
dcloud api sends one request with your sign-in, as gh api does. The paths are those of the
API Reference, not GitHub's. {repoId}, {owner}, {repo}, {branch} and {org} in a path
are filled from the current directory and your sign-in. It prints the data of the answer
(--raw prints the whole answer), --paginate follows nextCursor to the last page, and a URL
of another host is refused.
dcloud api 'git/api/repositories/{repoId}/pulls' -q '.[].title'
dcloud api 'git/api/repositories/{repoId}/labels' -f name=bug -f color=d73a4aWhere a command behaves differently
| Command | Difference |
|---|---|
| every command | It asks for nothing but the confirmation of a deletion (--yes answers it) and opens no editor. Without a flag it needs, it exits with code 2 and names the flag. |
pr create |
Needs --title or --fill. |
pr merge |
Without --merge, --squash or --rebase the method is a merge commit, or the first one the repository allows. --admin is refused: a branch rule has no bypass. |
pr checks, run list |
A check is a workflow run. Its status is one word, for example queued, running, succeeded, failed or cancelled. |
run view, run watch |
A run is named by its number or its id. |
run rerun |
--failed runs every job again and says so. --job is refused. |
repo list, search |
Your organization's repositories only. search matches words; it does not read GitHub's query syntax. |
repo fork |
The fork is a repository of the same organization, named my-repo-fork unless --fork-name says otherwise. |
repo sync |
Fast-forward only. |
repo edit |
A switch is a pair of flags, for example --enable-squash-merge and --disable-squash-merge. |
secret set, secret delete |
A secret belongs to the organization, and set grants the repository's runs read access to it. delete removes the grant. |
repo deploy-key delete |
Asks before it deletes, as every deletion does. |
ssh-key add |
Every key is an authentication key. --type signing is refused. |
browse |
--commit needs the commit. |
auth login |
--stdin reads an access key (gh: --with-token). A profile (--profile) stands for an account. |
What has no counterpart
--template(Go templates): use--jsonwith--jq.repo rename,repo set-default,pr revert,pr lock,issue delete,issue pin,issue lock,issue transfer,issue develop,run delete,workflow enableandworkflow disable.search codeandsearch commits.release create --generate-notes, and editing or deleting a comment (--edit-last,--delete-last).- What only GitHub has: gists, codespaces, projects, discussions, rulesets, caches, attestations, autolinks, and the gitignore and license templates.
For agents
Every operation is also a tool of the MCP server, named after the API: gh pr merge is
dcloud_git_pulls_merge. Where the name differs from the gh command, the tool's description
says which gh command it is the counterpart of, so a search for "gh pr merge" in the tool list
finds it. See MCP server.
Related
Related
- POST /git/api/repositories/{repoId}/pulls
- GET /git/api/repositories/{repoId}/pulls/{prNumber}
- GET /git/api/repositories/{repoId}/pulls/{prNumber}/diff
- POST /git/api/repositories/{repoId}/pulls/{prNumber}/reviews
- POST /git/api/repositories/{repoId}/pulls/{prNumber}/merge
- POST /git/api/repositories/{repoId}/releases
- GET /ci/api/repositories/{repoId}/runs
- GET /ci/api/runs/{runId}
- GET /ci/api/artifacts/{artifactId}/download