Skip to content

Commit

Permalink
docs: update document
Browse files Browse the repository at this point in the history
  • Loading branch information
KEINOS committed Feb 7, 2022
1 parent 3e23845 commit 43518cf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
[![Test](https://github.com/KEINOS/gh-action-hash-for-cache/actions/workflows/basic_func_test.yml/badge.svg)](https://github.com/KEINOS/gh-action-hash-for-cache/actions/workflows/basic_func_test.yml)
[![linux-mac-win](https://github.com/KEINOS/gh-action-hash-for-cache/actions/workflows/platform_test.yml/badge.svg)](https://github.com/KEINOS/gh-action-hash-for-cache/actions/workflows/platform_test.yml)

# GitHub Actions to Generate Hash for Caching on Linux, macOS, and Windows runners
# Unique Key (file hash) Generator for Caching

This GitHub Action generates a unique key (file hash) from one or more files for caching. It works on Linux, macOS, and Windows runners.

```yaml
- name: <name of the step to display>
uses: KEINOS/gh-action-hash-for-cache@main
id: <ID to call the hash from other steps>
with:
path: |
<path to target file1>
<path to target file2>
variant: <a string>
```
- `path`: A list of files that will be hashed.
- `variant`: A string to be hashed. (Optional)
- Exposed variable: `hash`
- To obtain the hash value: `steps.<id>.outputs.hash`

## About

[This GitHub Action](https://github.com/KEINOS/gh-action-hash-for-cache):

- **Simply generates a hash of the given entry**.
- If the content of the entry is changed, a different hash will be obtained.
- Useful to generate a key or ID for caching.
- Useful to generate a unique key or ID for caching.
- Works on Linux, macOS, and Windows runners.
- Aims to be a helper action for "[actions/cache@v2](https://github.com/marketplace/actions/cache)".
- It is also possible to specify a time-limited variant.
- It is also possible to specify a time-limited hash.
- Help us to fix [issues](https://github.com/KEINOS/gh-action-hash-for-cache/issues) @ GitHub.
- View on [marketplace](https://github.com/marketplace/actions/file-hash-for-cache).

## Usage

Expand Down Expand Up @@ -39,11 +61,29 @@ jobs:

- Exposed variables: `steps.<id>.outputs.hash`

## Example
## Examples

### On File Change

In this example, if "composer.json" or "composer.lock" is changed, the hash will be changed.
In this example, if "Dockerfile" is changed, the hash will be changed.

```yaml
- name: Get a hash key from two files
id: hash-now-dont-you-cry
uses: KEINOS/gh-action-hash-for-cache@main
with:
path: |
./Dockerfile
- name: Activate caching
id: cache
uses: actions/cache@v2
with:
path: /path/target/dir/to/cache/and/restore
key: ${{ steps.hash-now-dont-you-cry.outputs.hash }}
```

Multiple target files can be specified. The below example, if "composer.json" or "composer.lock" is changed, the hash will be changed.

```yaml
- name: Get a hash key from two files
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "File Hash for cache"
description: 'Generates a hash of the given entry for cache key.'
name: "File Hash for Cache"
description: 'Generates a unique key (hash) from one or more files for caching.'
author: 'KEINOS'

branding:
Expand Down

0 comments on commit 43518cf

Please sign in to comment.