name: Restore Tasks Cache CI
inputs:
  tag:
    required: false
    types: [string]
  tasks:
    required: false
    types: [string]
    default: all
  suffix:
    required: false
    types: [string]

runs:
  using: "composite"
  steps:
    - name: Compute tasks key
      id: tasks-key
      shell: bash
      run: echo "key=${{ inputs.tasks }}" | tr , - >> $GITHUB_OUTPUT
    - name: Restore tasks cache
      uses: actions/cache@v3
      with:
        path: |
          .cache
          .nx/cache
          node_modules/.cache
          packages/*/node_modules/.cache
        key: tasks-cache-${{ github.ref_name }}-${{ inputs.tag }}-${{ steps.tasks-key.outputs.key }}${{ inputs.suffix }}-${{ github.sha }}
        restore-keys: |
          tasks-cache-${{ github.ref_name }}-${{ inputs.tag }}-${{ steps.tasks-key.outputs.key }}${{ inputs.suffix }}-