To use GitHub action cache what do I set as the value for the "key" in the workflows.yml file?

Viewed 1699

I'm trying to use Github actions to deploy to S3. I have created my .github/workflows directory and been following a tutorial to help me write my workflows.yml file.

Everything seems to be working well until I come to needing to cache node_modules. The tutorial I was following doesn't elaborate or explain what value needs to be added to the "key" and where to get this value from. Currently I have just used the name of my repo, but I don't think this is correct. This is how the cache section of my .yml file looks now...

- name: Caching Gatsby
        id: gatsby-cache-build
        uses: actions/cache@v2
        with:
          path: |
            public
            .cache
            node_modules
          key: ${{ runner.os }}-gatsby-${{ github.run_id }}
          restore-keys: |
            ${{ runner.os }}-gatsby-

The error I receive when my action runs in Github is "Cache not found for input keys: Linux-gatsby-1563397146, Linux-gatsby-"

I've tried reading documentation on Github about the use of these keys but I'm finding them too hard to follow. I think there are specific values I need to use here depending on how the build script is running and how I do my installs. I'm allowing the build to run on ubuntu-latest and I use npm to do my installs and run build.

Can anyone tell me, what value do I use next to "key" and "restore-keys" and where do I get these from?

0 Answers
Related