actions / actions/cache

allow path parameter to be a YAML list

Open
#510 8 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
TypeScript
Stars
5.6k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

The README example shows how with.path is meant to be specified - as a multi-line YAML string:

- uses: actions/cache@v2
  with:
    path: |
      ~/cache
      !~/cache/exclude
      **/node_modules

This correlates with what we can see in the code: https://github.com/actions/cache/blob/354332455a7a9ae5492723ca9d4d082484e173bc/src/utils/actionUtils.ts#L56-L65

Unfortunately, this format is rather unfriendly to humans. It does not allow inline comments, for example, which would be really useful to document why certain paths are being cached. Worse even, attempting to use YAML-like comments results in silently broken caching; see https://github.com/mvdan/github-actions-golang/pull/16.

I assume this is rooted at how action inputs are strings. At an internal level, that makes sense. However, at the user-facing YAML level, I think this action should take a YAML list, not a list-encoded-in-newline-separated-strings multiline string. Internally, the Actions software could turn the YAML list into the newline-separated string, and that could be entirely transparent to the user:

- uses: actions/cache@v2
  with:
    path:
    - ~/cache
    - !~/cache/exclude # some comment
    - **/node_modules  # some other comment

I realise this is probably an issue that cannot be fixed in this repository alone, but I still think it belongs in this repository as it is a very clear example that's making actions/cache harder to use properly. I'm completely fine with this issue being moved elsewhere, but please don't close it as "not a bug in this repository" :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the README example and src/utils/actionUtils.ts lines 56-65 to understand the current newline-separated path handling. Check whether GitHub Actions can pass YAML lists to action inputs and whether the change belongs outside this repository. Done means supported YAML lists preserve paths and inline comments without silently breaking caching.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.