Repository: cli/cli

Issue:
Add `--actions` flag to `gh browse`
### Describe the feature or problem you’d like to solve

As per https://github.com/cli/cli/pull/12091, someone wants to jump to https://github.com/cli/cli/actions (repo equivalent).

### Proposed solution

Add `--actions` flag to `gh browse`.

### Additional context

I thought about whether this should go under `workflows` but it's not quite semantically the same as `workflows list`. We could do `gh workflows --web` but tbh that's a bigger departure than the current `gh browse` command.

Hints from issue comments:
@github-actions: Thank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, **we are not committing to implementing this feature at this time**, but, we will consider it for future releases based on community feedback and our own product roadmap. 

Unless you see the https://github.com/cli/cli/labels/help%20wanted label, we are not currently looking for external contributions for this feature.

**If you come across this issue and would like to see it implemented, please add a thumbs up!** This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.


Solution patch:
diff --git a/pkg/cmd/browse/browse.go b/pkg/cmd/browse/browse.go
index 68c97526a..a85b8ab7d 100644
--- a/pkg/cmd/browse/browse.go
+++ b/pkg/cmd/browse/browse.go
@@ -43,6 +43,7 @@ type BrowseOptions struct {
 	ReleasesFlag    bool
 	SettingsFlag    bool
 	WikiFlag        bool
+	ActionsFlag     bool
 	NoBrowserFlag   bool
 	HasRepoOverride bool
 }
@@ -116,24 +117,26 @@ func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co
 			}
 
 			if err := cmdutil.MutuallyExclusive(
-				"arguments not supported when using `--projects`, `--releases`, `--settings`, or `--wiki`",
+				"arguments not supported when using `--projects`, `--releases`, `--settings`, `--actions` or `--wiki`",
 				opts.SelectorArg != "",
 				opts.ProjectsFlag,
 				opts.ReleasesFlag,
 				opts.SettingsFlag,
 				opts.WikiFlag,
+				opts.ActionsFlag,
 			); err != nil {
 				return err
 			}
 
 			if err := cmdutil.MutuallyExclusive(
-				"specify only one of `--branch`, `--commit`, `--projects`, `--releases`, `--settings`, or `--wiki`",
+				"specify only one of `--branch`, `--commit`, `--projects`, `--releases`, `--settings`, `--actions` or `--wiki`",
 				opts.Branch != "",
 				opts.Commit != "",
 				opts.ProjectsFlag,
 				opts.ReleasesFlag,
 				opts.SettingsFlag,
 				opts.WikiFlag,
+				opts.ActionsFlag,
 			); err != nil {
 				return err
 			}
@@ -158,6 +161,7 @@ func NewCmdBrowse(f *cmdutil.Factory, runF func(*BrowseOptions) error) *cobra.Co
 	cmd.Flags().BoolVarP(&opts.ProjectsFlag, "projects", "p", false, "Open repository projects")
 	cmd.Flags().BoolVarP(&opts.ReleasesFlag, "releases", "r", false, "Open repository releases")
 	cmd.Flags().BoolVarP(&opts.WikiFlag, "wiki", "w", false, "Open repository wiki")
+	cmd.Flags().BoolVarP(&opts.ActionsFlag, "actions", "a", false, "Open repository actions")
 	cmd.Flags().BoolVarP(&opts.SettingsFlag, "settings", "s", false, "Open repository settings")
 	cmd.Flags().BoolVarP(&opts.NoBrowserFlag, "no-browser", "n", false, "Print destination URL instead of opening the browser")
 	cmd.Flags().StringVarP(&opts.Commit, "commit", "c", "", "Select another commit by passing in the commit SHA, default is the last commit")
@@ -223,6 +227,8 @@ func parseSection(baseRepo ghrepo.Interface, opts *BrowseOptions) (string, error
 		return "settings", nil
 	} else if opts.WikiFlag {
 		return "wiki", nil
+	} else if opts.ActionsFlag {
+		return "actions", nil
 	}
 
 	ref := opts.Branch



Test patch:
diff --git a/pkg/cmd/browse/browse_test.go b/pkg/cmd/browse/browse_test.go
index b38fa57f0..6d4476f3a 100644
--- a/pkg/cmd/browse/browse_test.go
+++ b/pkg/cmd/browse/browse_test.go
@@ -63,6 +63,14 @@ func TestNewCmdBrowse(t *testing.T) {
 			},
 			wantsErr: false,
 		},
+		{
+			name: "actions flag",
+			cli:  "--actions",
+			wants: BrowseOptions{
+				ActionsFlag: true,
+			},
+			wantsErr: false,
+		},
 		{
 			name: "no browser flag",
 			cli:  "--no-browser",
@@ -102,6 +110,15 @@ func TestNewCmdBrowse(t *testing.T) {
 			},
 			wantsErr: true,
 		},
+		{
+			name: "combination: actions wiki",
+			cli:  "--actions --wiki",
+			wants: BrowseOptions{
+				ActionsFlag: true,
+				WikiFlag:    true,
+			},
+			wantsErr: true,
+		},
 		{
 			name: "passed argument",
 			cli:  "main.go",
@@ -135,6 +152,11 @@ func TestNewCmdBrowse(t *testing.T) {
 			cli:      "main.go --wiki",
 			wantsErr: true,
 		},
+		{
+			name:     "passed argument and actions flag",
+			cli:      "main.go --actions",
+			wantsErr: true,
+		},
 		{
 			name: "empty commit flag",
 			cli:  "--commit",
@@ -215,6 +237,7 @@ func TestNewCmdBrowse(t *testing.T) {
 			assert.Equal(t, tt.wants.WikiFlag, opts.WikiFlag)
 			assert.Equal(t, tt.wants.NoBrowserFlag, opts.NoBrowserFlag)
 			assert.Equal(t, tt.wants.SettingsFlag, opts.SettingsFlag)
+			assert.Equal(t, tt.wants.ActionsFlag, opts.ActionsFlag)
 			assert.Equal(t, tt.wants.Commit, opts.Commit)
 		})
 	}
@@ -278,6 +301,14 @@ func Test_runBrowse(t *testing.T) {
 			baseRepo:    ghrepo.New("ravocean", "ThreatLevelMidnight"),
 			expectedURL: "https://github.com/ravocean/ThreatLevelMidnight/wiki",
 		},
+		{
+			name: "actions flag",
+			opts: BrowseOptions{
+				ActionsFlag: true,
+			},
+			baseRepo:    ghrepo.New("ravocean", "ThreatLevelMidnight"),
+			expectedURL: "https://github.com/ravocean/ThreatLevelMidnight/actions",
+		},
 		{
 			name:          "file argument",
 			opts:          BrowseOptions{SelectorArg: "path/to/file.txt"},