DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for GitHub CLI on Gitpod 🍊
Siddhant Khare
Siddhant Khare

Posted on • Updated on

GitHub CLI on Gitpod 🍊

What is GitHub CLI?

It is GitHub’s official command line tool. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code.

So, Recently GitHub CLI made a new update to Run Your GitHub Workflow Files through Command Line.

What is GitPod?

Gitpod is an open-source Kubernetes application for ready-to-code developer environments that spins up fresh, automated dev environments for each task, in the cloud, in seconds. It enables you to describe your dev environment as code and start instant, remote and cloud-based developer environments directly from your browser or your Desktop IDE.

Open Your GitHub Repository in Gitpod:

just add this prefix following to your github repository: https://gitpod.io/#

Example: https://gitpod.io/#https://github.com/GITHUB_USERNAME/REPOSITORY_NAME/

GitHub CLI Setup at Gitpod (official docs):

Run Following Commands:

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
Enter fullscreen mode Exit fullscreen mode
sudo apt update
sudo apt install gh
Enter fullscreen mode Exit fullscreen mode

Output:

Installation of GitHub CLI on Gitpod

Setting up the Workflow:

  • Create a empty file under .github/workflows/ named as github-action-demo.yml

  • File Content:

    name: Demo
    
    on:
    # Triggers the workflow on push or pull request events but only for the main branch
    pull_request:
        branches: [main]
    
    # Allows you to run this workflow manually from the Actions tab
    workflow_dispatch:
    
    jobs:
    cli-gitpod:
        name: CLI and Gitpod Demo
        runs-on: ubuntu-latest
        steps:
        - name: Hello From Gitpod
            run: |
            echo "Hello! From Gitpod 🍊"
    

Login with gh cli

  • Run:

    gh auth login
    
  • Complete whole step and login.

Test & Run GitHub Workflow with gh cli:

  • To View the list of your workflows:

    gh workflow list
    

you Will not see anything, because you first have to enbale that workflow.

  • To Enable the workflow:

    gh workflow enable
    

Workflow Enabled

  • To Run the Workflow:

    gh workflow run demo
    

Here demo was my workflow name, you can replace it with your workflow's name.

Workflow Run

On GitHub Dashboard:

GitHub Dashboard

  • run history list & analysis:

    gh run list --workflow=github-action-demo.yml
    

github-action-demo.yml is the filename, replace it with your workflow's filename.

Run List

  • Specific Result of any run ID:

    gh run view 1703727006
    

1703727006 is ID, replace it with your workflow run ID.

Github workflow run view


Similarly, You Can Run all GitHub CLI Commands in GitPod (gh cli commands)


Contribute in the browser using Gitpod

GitHub logo Siddhant-K-code / github-cli-on-gitpod

Test GitHub CLI on Gitpod

What is GitHub CLI?

It is GitHub’s official command line tool. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code.

So, Recently GitHub CLI made a new update to Run Your GitHub Workflow Files through Command Line.

What is GitPod?

Gitpod is an open-source Kubernetes application for ready-to-code developer environments that spins up fresh, automated dev environments for each task, in the cloud, in seconds. It enables you to describe your dev environment as code and start instant, remote and cloud-based developer environments directly from your browser or your Desktop IDE.

Open Your GitHub Repository in Gitpod:

just add this prefix following to your github repository: https://gitpod.io/#

Example: https://gitpod.io/#https://github.com/GITHUB_USERNAME/REPOSITORY_NAME/

GitHub CLI Setup at Gitpod (official docs):

Run Following Commands:

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture
…
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
pawlean profile image
Pauline P. Narvas (Paw)

Awesome post, Siddhant!

Collapse
siddhantkcode profile image
Siddhant Khare Author

Thanks, Pauline :)

Find what you were looking for? Sign up so you can:

Β 
🌚 Enable dark mode
πŸ”  Change your default font
πŸ“š Adjust your experience level to see more relevant content