0

In the following workflow, I want to add cache functionality so that, every time it will build from scratch. this is the workflow:

# This workflow will do
# a clean install of node deps
# build the source code
# run test across different versions of node

name: Conflict Check
on:
  push:
    branches:
      - staging
  pull_request:
    branches:
      - staging

jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - uses: mschilde/auto-label-merge-conflicts@master
        with:
          CONFLICT_LABEL_NAME: 'has conflicts'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

How can I achieve this?

Ashik
  • 2,888
  • 8
  • 28
  • 53

1 Answers1

0

You can use actions/cache action for purposes of caching in Github Actions.

jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - name: Cache build files
        uses: actions/cache@v2
        with:
          path: ${{ PATH_TO_CACHE }}
          key:${{ runner.os }}-${{ hashFiles(<glob_pattern_for_files>) }}
      - uses: mschilde/auto-label-merge-conflicts@master
        with:
          CONFLICT_LABEL_NAME: 'has conflicts'
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The example above assumes you want to cache your files between runs on different refs but your actual key declaration would depend on what you are trying to do.

For example if you are trying to cache between jobs or workflow runs on same ref:

key: ${{ runner.os }}-${{ github.sha }}
Matthew
  • 1,905
  • 3
  • 19
  • 26