Skip to content

pr checks: open target url for external ci #4002

Description

@rsteube

Describe the feature or problem you’d like to solve

gh pr checks --web opens by default the page for github actions which is empty when using a different ci like circleci.

Proposed solution

  1. Change the web flag to String with an optional argument to open the taget url for a specific build:
    gh pr checks --web="ci/circleci: build"
  2. provide a selection via survey
for _, c := range pr.StatusCheckRollup.Nodes[0].Commit.StatusCheckRollup.Contexts.Nodes {
	if c.Context == "ci/circleci: build" {
		return opts.Browser.Browse(c.TargetURL)
	}
}

Additional context

pkg/actions/git on  git-staged-changes [$] via  v1.16.5 on ☁  (eu-central-1) with elvish
❯ gh pr checks
All checks were successful
0 failing, 1 successful, and 0 pending checks

✓  ci/circleci: build    https://circleci.com/gh/rsteube/carapace-bin/1184?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

Activity

  1. mislav commented on Jul 15, 2021

    @mislav
    Contributor

    Thanks for the suggestion!

    Note that right now you could maybe get away with scripting your use-case:

    $ gh alias set build-view -s 'url="$(gh pr view $2 --json statusCheckRollup --jq ".statusCheckRollup[]|select(.context==\"$1\")|.targetUrl")"; [ -n "$url" ] && open "$url"'
    
    $ gh build-view "ci/circleci: current" https://github.com/rsteube/carapace/pull/310
    # or for the current PR:
    $ gh build-view "ci/circleci: current"
  2. rsteube commented on Jul 16, 2021

    @rsteube
    ContributorAuthor

    Using it indexed with default of 0 so i can just run gh build-view for the current first job (which is good enough in my case).

    gh alias set build-view '!url="$(gh pr view $2 --json statusCheckRollup --jq ".statusCheckRollup[${1:-0}].targetUrl")"; [ -n "$url" ] && xdg-open "$url"'
  3. nightpool commented on Aug 8, 2022

    @nightpool

    Just came here to report this issue as well! I always forget that --web doesn't work like this, and i always end up staring at the empty github "checks" screen before I realize my mistake. Would be great to make --web just do the right thing automatically be default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-prrelating to the gh pr command

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions