Sitelet https://web.archive.org/web/20200911235141/https://github.com/cli/cli/issues/1540
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on how to run from Github Actions CI/CD Workflow #1540

Open
aaronsteers opened this issue Aug 15, 2020 · 4 comments
Open

Add docs on how to run from Github Actions CI/CD Workflow #1540

aaronsteers opened this issue Aug 15, 2020 · 4 comments
Labels

Comments

@aaronsteers
Copy link

@aaronsteers aaronsteers commented Aug 15, 2020

Describe the feature or problem you’d like to solve

I'd like to be able to run gh cli from within a github action. The only install action I see is to manually download on the linux-based github runner (container) is to curl a hard-coded url, which will be immediately stale and will need it's version updated periodically. Is this the best way? Is it already installed on github runners? Some documentation here would be extremely helpful. Thanks!

Proposed solution

Documentation on the recommended way to run within github actions would be much appreciated.

Additional context

I've searched google and the available repo docs and github docs to no avail.

@aaronsteers
Copy link
Author

@aaronsteers aaronsteers commented Aug 15, 2020

Update: Installing works with the below but it fails to authenticate, prompting for a GUI-based URL MFA.

      - name: Install GitHub CLI
        run: |
          URL=https://github.com/cli/cli/releases/download/v0.11.1/gh_0.11.1_linux_amd64.deb
          TEMP_DIR="$(pwd)"
          TEMP_DEB="$(pwd)/gh_0.11.1_linux_amd64.deb"
          wget -O "$TEMP_DEB" "$URL"
          ls -la $TEMP_DIR
          sudo apt install "$TEMP_DEB"
          rm -f "$TEMP_DEB"

Failure log:

Run echo "Checking out from PR URL: https://api.github.com/repos/slalom-ggp/dataops-infra/pulls/122"
Checking out from PR URL: https://api.github.com/repos/slalom-ggp/dataops-infra/pulls/122
Notice: authentication required
Press Enter to open github.com in your browser... /usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'https://github.com/login/oauth/authorize?client_id=178c6fc778ccc68e1d6a&redirect_uri=http%3A%2F%2F127.0.0.1%3A33511%2Fcallback&scope=repo+read%3Aorg+gist&state=2f9d7df6cfbb09aefbf7'
error opening web browser: exit status 3
Please open the following URL manually:
https://github.com/login/oauth/authorize?client_id=178c6fc778ccc68e1d6a&redirect_uri=http%3A%2F%2F127.0.0.1%3A33511%2Fcallback&scope=repo+read%3Aorg+gist&state=2f9d7df6cfbb09aefbf7
If you are on a server or other headless system, use this workaround instead:
  1. Complete authentication on a GUI system;
  2. Copy the contents of `~/.config/gh/hosts.yml` to this system.
@aaronsteers
Copy link
Author

@aaronsteers aaronsteers commented Aug 15, 2020

Any plans to do something like https://github.com/marketplace/actions/setup-hub?

@mislav
Copy link
Member

@mislav mislav commented Aug 17, 2020

@aaronsteers GitHub CLI is pre-installed in Actions runners. To use it:

- uses: actions/checkout@v2

- name: GitHub CLI example
  run: gh issue list
  env:
    GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

I understand that this has to be better documented; I'll add a label as a TODO item for us. Thanks for your ask!

@mislav mislav added the docs label Aug 17, 2020
@aaronsteers
Copy link
Author

@aaronsteers aaronsteers commented Aug 17, 2020

@mislav - Awesome. That's a big help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.