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

Support for viewing, managing, and accessing workflow artifacts #6532

Open
andyfeller opened this issue Oct 30, 2022 · 5 comments
Open

Support for viewing, managing, and accessing workflow artifacts #6532

andyfeller opened this issue Oct 30, 2022 · 5 comments
Labels
enhancement a request to improve CLI

Comments

@andyfeller
Copy link
Contributor

Describe the feature or problem you’d like to solve

I would like greater visibility and capabilities around GitHub Actions workflow artifacts than the current information in gh run view #:

$ gh run list
STATUS  TITLE                     WORKFLOW                  BRANCH  EVENT              ID          ELAPSED  AGE
✓       Workflow artifacts reuse  Workflow artifacts reuse  main    workflow_dispatch  3348171091  13s      9m

$ gh run view 3348171091

✓ main Workflow artifacts reuse · 3348171091
Triggered via workflow_dispatch about 10 minutes ago

JOBS
✓ Generate and upload workflow artifact in 2s (ID 9171853255)
✓ Download and use workflow artifact in 2s (ID 9171853466)

ARTIFACTS
upload-artifacts

For any automation for leveraging these artifacts, it is possible for users to string together the necessary gh api calls to work with them based on the GitHub REST APIs for Artifacts:

  • List artifacts for a repository

    $ gh api /repos/{owner}/{repo}/actions/artifacts
    {
      "total_count": 1,
      "artifacts": [
        {
          "id": 416002865,
          "node_id": "MDg6QXJ0aWZhY3Q0MTYwMDI4NjU=",
          "name": "upload-artifacts",
          "size_in_bytes": 4125,
          "url": "https://api.github.com/repos/tinyfists/actions-experiments/actions/artifacts/416002865",
          "archive_download_url": "https://api.github.com/repos/tinyfists/actions-experiments/actions/artifacts/416002865/zip",
          "expired": false,
          "created_at": "2022-10-28T19:59:18Z",
          "updated_at": "2022-10-28T19:59:18Z",
          "expires_at": "2023-01-26T19:59:13Z",
          "workflow_run": {
            "id": 3348171091,
            "repository_id": 558999734,
            "head_repository_id": 558999734,
            "head_branch": "main",
            "head_sha": "dc28f5766a1012f92225971dc38147fad43b8f75"
          }
        }
      ]
    }
  • Get an artifact

    $ gh api /repos/{owner}/{repo}/actions/artifacts/416002865
    {
      "id": 416002865,
      "node_id": "MDg6QXJ0aWZhY3Q0MTYwMDI4NjU=",
      "name": "upload-artifacts",
      "size_in_bytes": 4125,
      "url": "https://api.github.com/repos/tinyfists/actions-experiments/actions/artifacts/416002865",
      "archive_download_url": "https://api.github.com/repos/tinyfists/actions-experiments/actions/artifacts/416002865/zip",
      "expired": false,
      "created_at": "2022-10-28T19:59:18Z",
      "updated_at": "2022-10-28T19:59:18Z",
      "expires_at": "2023-01-26T19:59:13Z",
      "workflow_run": {
        "id": 3348171091,
        "repository_id": 558999734,
        "head_repository_id": 558999734,
        "head_branch": "main",
        "head_sha": "dc28f5766a1012f92225971dc38147fad43b8f75"
      }
    }
  • Delete an artifact

    $ gh api -X DELETE /repos/{owner}/{repo}/actions/artifacts/416002865
    
    $ gh api /repos/{owner}/{repo}/actions/artifacts
    {
      "total_count": 0,
      "artifacts": []
    }
  • Download an artifact

    # NOTE: Must redirect output to file as `gh api` will follow redirect and stream binary data
    $ gh api /repos/{owner}/{repo}/actions/artifacts/416002865/zip > 416002865.zip
  • List workflow run artifacts

    $ gh api /repos/{owner}/{repo}/actions/runs/3348171091/artifacts
    {
      "total_count": 1,
      "artifacts": [
        {
          "id": 416002865,
          "node_id": "MDg6QXJ0aWZhY3Q0MTYwMDI4NjU=",
          "name": "upload-artifacts",
          "size_in_bytes": 4125,
          "url": "https://api.github.com/repos/tinyfists/actions-experiments/actions/artifacts/416002865",
          "archive_download_url": "https://api.github.com/repos/tinyfists/actions-experiments/actions/artifacts/416002865/zip",
          "expired": false,
          "created_at": "2022-10-28T19:59:18Z",
          "updated_at": "2022-10-28T19:59:18Z",
          "expires_at": "2023-01-26T19:59:13Z",
          "workflow_run": {
            "id": 3348171091,
            "repository_id": 558999734,
            "head_repository_id": 558999734,
            "head_branch": "main",
            "head_sha": "dc28f5766a1012f92225971dc38147fad43b8f75"
          }
        }
      ]
    }

Proposed solution

While GitHub Action workflows can leverage actions/download-artifact, I believe this is limited in terms of how automation and developers interact with artifacts.

Some ideas of how this might be incorporated into GitHub CLI:

  1. Viewing artifacts

    $ gh artifact list
    
    NAME              ID         SIZE    RUN ID      CREATED  EXPIRES  EXPIRED
    upload-artifacts  416002865  #bytes  3348171091  #m       #d       false
    ...
  2. Downloading artifact

    $ gh artifact download ##

    Will admit, I'm not sure a recommendation on providing a name for the downloaded artifact as well as any of the capabilities from https://github.com/actions/download-artifact for extracting files from the archive.

  3. Deleting artifact

    $ gh artifact delete ##
  4. Viewing artifact

    $ gh artifact view ##

    Could have --web go to the workflow run associated with it.

While I wish this suggestion was some grand solution to a major problem with enormous benefits, I will admit that this is mostly for providing views that are not readily available in the UI and cutting down on writing API calls manually for all of this.

Screen Shot 2022-10-30 at 3 36 54 PM

As you can see in the screenshot above, there is no UI information around repository-wide artifacts like shown by API.

Additional context

Add any other context like screenshots or mockups are helpful, if applicable.

@andyfeller andyfeller added the enhancement a request to improve CLI label Oct 30, 2022
@cliAutomation cliAutomation added the needs-triage needs to be reviewed label Oct 30, 2022
@mislav mislav added discuss Feature changes that require discussion primarily among the GitHub CLI team and removed needs-triage needs to be reviewed labels Oct 31, 2022
@mislav
Copy link
Contributor

mislav commented Oct 31, 2022

Thanks for the detailed feature request! We will discuss which of these features we'd want in core.

2. Downloading artifact

Note the existing command gh run download 🙇

@andyfeller
Copy link
Contributor Author

Very good to know!

In writing this, I wrestled with what would be beneficial beyond the artifact information within a workflow run. I hadn't seen any hard documentation on workflow artifact expiration or understand how customers are using or operationalizing artifacts for an entire repo. So with all of that being said, I won't be disappointed if this isn't a priority 🙇

@mislav
Copy link
Contributor

mislav commented Nov 1, 2022

We're for exposing the workflow artifacts a bit better, but in a relatively simple way. Since we already have the download command, we're thinking of just adding commands to list the artifacts and to manually delete the artifacts. But, we don't think this is deserving of a top-level command, so we're thinking of nesting it under gh run artifact or gh workflow artifact.

What do you think?

@mislav mislav removed the discuss Feature changes that require discussion primarily among the GitHub CLI team label Nov 1, 2022
@andyfeller
Copy link
Contributor Author

andyfeller commented Nov 10, 2022

We're for exposing the workflow artifacts a bit better, but in a relatively simple way. Since we already have the download command, we're thinking of just adding commands to list the artifacts and to manually delete the artifacts. But, we don't think this is deserving of a top-level command, so we're thinking of nesting it under gh run artifact or gh workflow artifact.

What do you think?

Note
Personal opinions, take with 🧂

The question that comes to mind is "how are people using artifacts beyond the workflow run scope?"

As we can see, artifacts are repository-wide as well as workflow run specific. I don't have the full grasp on all the use cases around artifacts to demonstrate how repository-wide artifacts are used.

My original assumption was having objects / concepts as the top level with verbs following. This would also allow artifacts to appear more predominantly in the usage around GitHub Actions commands without being buried:

USAGE
  gh <command> <subcommand> [flags]

CORE COMMANDS
  auth:        Authenticate gh and git with GitHub
  browse:      Open the repository in the browser
  codespace:   Connect to and manage codespaces
  gist:        Manage gists
  issue:       Manage issues
  pr:          Manage pull requests
  release:     Manage releases
  repo:        Manage repositories

ACTIONS COMMANDS
  run:         View details about workflow runs
  workflow:    View details about GitHub Actions workflows

Between gh run artifact and gh workflow artifact, my opinion is that gh workflow artifact would let repository-wide artifact commands live separate from workflow run artifact commands.

@andyfeller
Copy link
Contributor Author

One thing that fell short of my original idea is making it easy to upload artifacts, too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request to improve CLI
Projects
None yet
Development

No branches or pull requests

3 participants