devshop / github-api-cli
Simple console wrapper for GitHub API
Requires
- php: ^7.1||^8.0
- consolidation/robo: ^2
- devshop/git-traits: @dev
- guzzlehttp/guzzle: ^6
- knplabs/github-api: ^3.9||^1.0
- php-http/guzzle6-adapter: 2.x-dev
- 2.x-dev
- 1.x-dev
- 1.8.x-dev
- 1.8.0-beta3
- 1.8.0-beta2
- 1.8.0-beta1
- 1.8.0-alpha1
- 1.7.x-dev
- 1.7.0-alpha4
- 1.7.0-alpha3
- 1.7.0-alpha2
- 1.7.0-alpha1
- 1.6.0-alpha4
- dev-bug/bitbucket-builds
- dev-bug/bitbucket/integration
- dev-bug/build-fast
- dev-bug/composer-broke
- dev-bug/composer-install-fails-preserve-paths
- dev-bug/deploy
- dev-bug/deploy-apis
- dev-bug/destroyed
- dev-bug/docker-logs-artifacts
- dev-bug/docker/actions
- dev-bug/docker/hub
- dev-bug/everything
- dev-bug/failing-again
- dev-bug/fucked-containers
- dev-bug/full-stack-stuff
- dev-bug/github/actions
- dev-bug/last-passing-commit
- dev-bug/little-things
- dev-bug/local/docker-command
- dev-bug/no-drush
- dev-bug/provision-files
- dev-bug/queues
- dev-bug/remote-hosts
- dev-bug/reset
- dev-bug/sync
- dev-bug/tasks
- dev-bug/ubuntu-scripts
- dev-bug/unpreserved-paths
- dev-bug/updated-containers
- dev-bug/upgrade
- dev-bug/verify
- dev-bug/verify-fail-after-install
- dev-bugs/beta-blockers
- dev-bugs/contrib
- dev-bugs/various
- dev-component/devshop-behat-extension
- dev-dev/github/fixes
- dev-dev/stuff
- dev-feature/ansible-tweaks
- dev-feature/ansible/faster
- dev-feature/bitbucket-fixes
- dev-feature/commands
- dev-feature/development/lando
- dev-feature/devshop-control-in-root
- dev-feature/devshop-platform
- dev-feature/drupal-10
- dev-feature/hosting/default_hosting_settings
- dev-feature/hosting_docker
- dev-feature/linuxserver
- dev-feature/megamerge
- dev-feature/minor-ansible-improvements
- dev-feature/no-platforms
- dev-feature/php-81-default
- dev-feature/php-intl
- dev-feature/php/8.1-default
- dev-feature/platform-user
- dev-feature/reinstall
- dev-feature/release-docs
- dev-feature/remote-host-container
- dev-feature/site-audit
- dev-feature/ubuntu22
- dev-release-1.8.0-beta1
- dev-release-1.8.0-beta2
- dev-tests/docker/from-devshop-server
- dev-tests/failing-install
- dev-updates/2023-10
- dev-bug/github/settings-ui
- dev-bug/ansible/detect-site
- dev-bug/docker/no-buildtime-tag
- dev-bug/hosting-queue-runner-commands
- dev-dev/install/platforms
- dev-feature/composer/git-traits
- dev-feature/docker/hub-publish
- dev-feature/php/8.1
- dev-ops/ansible/default-project-vars
- dev-php81
- dev-bug/docker/build-again
- dev-bug/docker/removed-too-much
- dev-bug/scripts/fix-path
- dev-bug/sites/git-reset
- dev-feature/components/php-8
- dev-feature/docker/build-run
- dev-feature/docker/fix-it-all
- dev-feature/os/ubuntu20
- dev-feature/os/ubuntu2004
- dev-feature/php-8
- dev-feature/php/8
- dev-feature/php/8.0
- dev-feature/robo/cleanup
- dev-feature/php80
- dev-bug/ch112/release-fixes
- dev-bug/ch118/provision-release
- dev-bug/ch118/test-fails
- dev-bug/ch118/uid-reset
- dev-bug/ch122/test-devshop-control
- dev-bug/ch177/detect-hostname
- dev-bug/ch185/composer-1
- dev-bug/ch185/composer-2
- dev-bug/ch460/bad-1.x-builds
- dev-bug/ch460/scheduled-build-branch
- dev-bug/ch472/composer-devshop-control
- dev-bug/ch477/composer-tests
- dev-bug/ch477/lost-control
- dev-bug/ch479/simplify-ansible-inventory-generation
- dev-bug/ch504/1x-ci-fail
- dev-bug/ch505/ansible-role-vars
- dev-bug/ch586/main-branch-tests
- dev-bug/ch587/install-sh-forks
- dev-bug/chXYZ/yaml-tasks-bugs
- dev-bug/components-ci-fail
- dev-bug/composer-ansible-fail
- dev-bug/composer-common-installable
- dev-bug/composer-fail
- dev-bug/docker-compose-up
- dev-bug/gh385/deploy
- dev-bug/gh642/disabled-sites
- dev-bug/gh656/protect-site
- dev-bug/git-split/composer-plugin-api-version
- dev-bug/hosting-queue-stop
- dev-bug/install-builder
- dev-bug/pr655/tests-failing
- dev-bug/tests-and-local
- dev-component/composer/deploy
- dev-component/devmaster/task-line-numbers
- dev-dependabot/add-v2-config-file
- dev-dev/environment/classes
- dev-dev/support/fixes
- dev-dev/ux/task-site-urls
- dev-dev/ux/tasks
- dev-feature/ch115/hugo-site
- dev-feature/ch121/links-to-domains
- dev-feature/ch139/ansible-cloud
- dev-feature/ch139/repos
- dev-feature/ch256/devshop-developers
- dev-feature/ch475/better-install-sh
- dev-feature/ch534/github-actions-checkout
- dev-feature/ch584/better-dx
- dev-feature/ch86/deploy
- dev-feature/ch86/deploy-component
- dev-feature/ch90/readme
- dev-feature/gh644/devshop-control-codebase
- dev-feature/gh644/path-devmaster-repo
- dev-feature/git-remote-monitor
- dev-feature/php-versions
- dev-feature/shape-up
- dev-feature/ubuntu20
- dev-ops/ansible/update
- dev-pr/655
- dev-release-1.7.0
- dev-testing/php74
- dev-tests/control/pseudo-repo
- dev-ux/create/redirect
- dev-feature/ch81/composer-devshop
- dev-integration
- dev-component/composer/devmaster
- dev-bug/ch101/devshop-test-volumes
- dev-bug/ch17/test-assets-folder
- dev-bug/ch20/ansible-lint
- dev-bug/ch35/tests-passing
- dev-bug/ch36/little-bugs
- dev-ci/install/devshop-tech
- dev-ci/makefiles/ci-makefile
- dev-component/composer/set-path
- dev-components
- dev-dev/devshop/docker-tools
- dev-feature/ch37/dev-environment
- dev-feature/ch87/rapid-tests
- dev-feature/ch87/rapid-tests-2
- dev-feature/ch89/core-values
- dev-feature/test-composer-template
- dev-install/install-sh/ansible-pip
- dev-ops/docker/dockerfiles
- dev-ops/os/centos8
- dev-pull/589
- dev-component/docs
- dev-composer/node/suggests
- dev-install/get.devshop.tech
- dev-ci/github/actions-branches
- dev-ci/github/actions-fixes
- dev-component/github-api-cli/ssl-ignore
- dev-dependabot/composer/composer/composer-1.10.4
- dev-dependabot/composer/composer/composer-1.10.5
- dev-develop
- dev-component/github-api-cli/deployments
- dev-component/common
- dev-component/github-cli
- dev-dependabot/composer/drush/drush-10.2.2
This package is auto-updated.
Last update: 2024-12-04 12:41:23 UTC
README
The GitHubApiCli component a simple console wrapper for the GitHub API to allow abstract command line interaction.
Built on knp-labs/github-api.
Usage
composer require devshop/github-api-cli
export GITHUB_TOKEN=aRealToken
bin/github whoami
--------------------------- ----------------------------------------------------------------
Name Value
--------------------------- ----------------------------------------------------------------
login devshopbot
id 11931385
node_id MDQ6VXNlcjExOTMxMzg1
avatar_url https://avatars2.githubusercontent.com/u/11931385?v=4
gravatar_id
url https://api.github.com/users/devshopbot
html_url https://github.com/devshopbot
followers_url https://api.github.com/users/devshopbot/followers
following_url https://api.github.com/users/devshopbot/following{/other_user}
gists_url https://api.github.com/users/devshopbot/gists{/gist_id}
starred_url https://api.github.com/users/devshopbot/starred{/owner}{/repo}
subscriptions_url https://api.github.com/users/devshopbot/subscriptions
organizations_url https://api.github.com/users/devshopbot/orgs
repos_url https://api.github.com/users/devshopbot/repos
events_url https://api.github.com/users/devshopbot/events{/privacy}
received_events_url https://api.github.com/users/devshopbot/received_events
type User
site_admin
name devshopbot
company
blog
location
email
hireable
bio
public_repos 2
public_gists 0
followers 0
following 0
created_at 2015-04-13T20:05:05Z
updated_at 2020-02-28T17:13:13Z
private_gists 0
total_private_repos 0
owned_private_repos 0
disk_usage 0
collaborators 0
two_factor_authentication
--------------------------- ----------------------------------------------------------------
Commands
github api
Passes directly to `GitHub\Api\AbstractAPI classes.
./github api me
--------------------------- ----------------------------------------------------------------
Name Value
--------------------------- ----------------------------------------------------------------
login devshopbot
id 11931385
node_id MDQ6VXNlcjExOTMxMzg1
avatar_url https://avatars2.githubusercontent.com/u/11931385?v=4
Only "show" works right now, but it should successfully return any object.
/github api user show jonpugh
--------------------- -------------------------------------------------------------
Name Value
--------------------- -------------------------------------------------------------
login jonpugh
id 106420
node_id MDQ6VXNlcjEwNjQyMA==
avatar_url https://avatars2.githubusercontent.com/u/106420?v=4
gravatar_id
url https://api.github.com/users/jonpugh
html_url https://github.com/jonpugh
followers_url https://api.github.com/users/jonpugh/followers
Load info about an organization:
./github api organization show department-of-veterans-affairs
--------------------------- ------------------------------------------------------------------------------------
Name Value
--------------------------- ------------------------------------------------------------------------------------
login department-of-veterans-affairs
id 5421563
node_id MDEyOk9yZ2FuaXphdGlvbjU0MjE1NjM=
url https://api.github.com/orgs/department-of-veterans-affairs
repos_url https://api.github.com/orgs/department-of-veterans-affairs/repos
Show info about a repo:
./github api repo show department-of-veterans-affairs va.gov-cms
------------------- -----------------------------------------------------------------------------------------------------------------
Name Value
------------------- -----------------------------------------------------------------------------------------------------------------
id 154174777
node_id MDEwOlJlcG9zaXRvcnkxNTQxNzQ3Nzc=
name va.gov-cms
full_name department-of-veterans-affairs/va.gov-cms
private
html_url https://github.com/department-of-veterans-affairs/va.gov-cms
github deployment:start
Creates a new deployment and saves the ID as a git config item.
bin/github deployment:start --environment=dev --description="Manual deployment triggered as an example."
Then use deployment:update
to change the status.
github deployment:update
Updates the status of a deployment.
bin/github deployment:update --state=in_progress --description="Building our thing..." --log_url=$OUR_BUILD_LOGS_URL
You can use bash operators to set different state based on exit code of a script.
Use &&
after a command to designate a command to run on success.
Use ||
after a command to designate a command to run on failure.
deploy.sh \
&& bin/github deployment:update --state=success --description="This deployment update will only happen if deploy.sh returns exit code 0" \
|| ( bin/github deployment:update --state=failure --description="This deployment update will only happen if deploy.sh returns exit 1." && exit 1 )
See The DevShop Build tests as an example https://github.com/opendevshop/devshop/blob/09fbf10286994c378fa24cf6b9f91e9df33928dd/.github/workflows/build.yml#L110
If you are using a CI runner, be sure to exit 1
after the failure command, to
ensure the overall script exits with a failure as well.
SSL Issues
If you encounter any SSL errors, such as the one below, you can tell the HTTPClient Library Guzzle to skip SSL verification.
60: SSL certificate problem: self signed certificate in certificate chain
All DevShop components that use the GitHub API can be configured to skip the SSL certificate verification. Set the following environment variable to ignore SSL errors:
export DEVSHOP_GITHUB_API_IGNORE_SSL=1
See YamlTasksConsoleCommand.php and GitHubApiCli.php to see the implementation.
Resources
Credits
$CREDITS