Launching and watching GitHub Action Workflows from the CLI
So What
I don't have to leave my terminal, i.e. work tool of choice, to mess with my CI/CD
Today I learned that you can use the gh CLI to launch and watch GitHub Action runs.
The CLI is pretty smart too. It checks the remote of the current repository you are in. No need to manually specify for which repository this the run is supposed to happen.
This workflow has a dispatch trigger and defines two boolean inputs that it can take, which we can also specify from the CLI.
gh workflow run build-deploy-prod.yml -f tag=v0.3.0 -f build=false -f deploy=true
✓ Created workflow_dispatch event for build-deploy-prod.yml at main
https://github.com/<org>/<repository>/actions/runs/38713551905
To see the created workflow run, try: gh run view 38713551905
To see runs for this workflow, try: gh run list --workflow="build-deploy-prod.yml"
It then returned the ID of the run which we can use further, with the watch command for example. This command polls-for-status and we get updates on the progress of jobs as they complete.
gh run watch 38713551905
✓ main Build And Deploy (Production) · 38713551905
Triggered via workflow_dispatch about 4 minutes ago
JOBS
✓ deploy / verify in 9s (ID 116350621939)
✓ Set up job
✓ Check tag fits environment
✓ Run docker/login-action@v4
✓ Check image is pullable
✓ Post Run docker/login-action@v4
✓ Complete job
- build in 0s (ID 116350623867)
✓ deploy / deploy in 4m21s (ID 116350706577)
✓ Set up job
✓ Run aws-actions/configure-aws-credentials@v6
✓ Download existing task definition
✓ Run aws-actions/amazon-ecs-render-task-definition@v1
✓ Run aws-actions/amazon-ecs-deploy-task-definition@v2
✓ Record the deployed tag for Terraform
✓ Post Run aws-actions/configure-aws-credentials@v6
✓ Complete job
Really neat feature and another good tool to quickly check workflows without needing to leave the terminal!