Skip to content

Does not work with directories if the target path already exists #16

@JordanPFVR

Description

@JordanPFVR
      - name: Local cache for current JS Bundle based on SHA
        id: js-bundle-cache
        uses: MasterworksIO/action-local-cache@2
        with:
          path: './release/app'
          key: ${{ steps.read_yaml.outputs.sha }}

For the following configuration the post step will successfully cache the ./release/app directory under the correct path intentional path (prefix'd with the org name and cache key).

On subsequent runs, if the path defined by targetPath already exists, @actions/io mv will append the target path with the basename of the given path...

We can see this behaviour here: https://github.com/actions/toolkit/blob/main/packages/io/src/io.ts#L91

The result is the cache is incorrectly restored into ./release/app/app/.

The fix is to use targetDir rather than targetPath when working with directories.
https://github.com/MasterworksIO/action-local-cache/blob/main/src/main.ts#L15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions