Skip to content

Commit 4f9af02

Browse files
committed
Merge branch 'release-v1'
2 parents da2c092 + fc9d998 commit 4f9af02

20 files changed

+6317
-595
lines changed

.github/workflows/test.yml

-24
This file was deleted.

README.md

+17-89
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,33 @@
1-
<p align="center">
2-
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
3-
</p>
1+
# Local Cache javascript action
42

5-
# Create a JavaScript Action using TypeScript
3+
This action caches artifacts to improve workflow execution time on self hosted machine.
4+
Artifacts are cached in the /tmp/.cache.
65

7-
Use this template to bootstrap the creation of a TypeScript action.:rocket:
6+
## Inputs
87

9-
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
8+
### `base`
109

11-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
10+
**Optional** A top directory to cache and restore.
1211

13-
## Create an action from this template
12+
### `path`
1413

15-
Click the `Use this Template` and provide the new repo details for your action
14+
**Required** A directory to cache and restore.
1615

17-
## Code in Main
16+
### `key`
1817

19-
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
18+
**Required** An explicit key for a cache entry.
2019

21-
Install the dependencies
22-
```bash
23-
$ npm install
24-
```
25-
26-
Build the typescript and package it for distribution
27-
```bash
28-
$ npm run build && npm run package
29-
```
30-
31-
Run the tests :heavy_check_mark:
32-
```bash
33-
$ npm test
34-
35-
PASS ./index.test.js
36-
✓ throws invalid number (3ms)
37-
wait 500 ms (504ms)
38-
test runs (95ms)
39-
40-
...
41-
```
20+
## Outputs
4221

43-
## Change action.yml
22+
### `cache-hit`
4423

45-
The action.yml defines the inputs and output for your action.
24+
Cache hit or not
4625

47-
Update the action.yml with your name, description, inputs and outputs for your action.
48-
49-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
50-
51-
## Change the Code
52-
53-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
54-
55-
```javascript
56-
import * as core from '@actions/core';
57-
...
58-
59-
async function run() {
60-
try {
61-
...
62-
}
63-
catch (error) {
64-
core.setFailed(error.message);
65-
}
66-
}
67-
68-
run()
69-
```
70-
71-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
72-
73-
## Publish to a distribution branch
74-
75-
Actions are run from GitHub repos so we will checkin the packed dist folder.
76-
77-
Then run [ncc](https://github.com/zeit/ncc) and push the results:
78-
```bash
79-
$ npm run package
80-
$ git add dist
81-
$ git commit -a -m "prod dependencies"
82-
$ git push origin releases/v1
83-
```
84-
85-
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project.
86-
87-
Your action is now published! :rocket:
88-
89-
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
90-
91-
## Validate
92-
93-
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
26+
## Example usage
9427

9528
```yaml
96-
uses: ./
29+
uses: corca-ai/local-cache@1
9730
with:
98-
milliseconds: 1000
31+
path: node_modules
32+
key: ${{ hashFiles('yarn.lock') }}
9933
```
100-
101-
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
102-
103-
## Usage:
104-
105-
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action

action.yml

+17-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
name: 'Your name here'
2-
description: 'Provide a description here'
3-
author: 'Your name or organization here'
1+
name: 'local-cache'
2+
description: 'Cache artifacts to improve workflow execution time on self hosted machine'
43
inputs:
5-
milliseconds: # change this
4+
base:
5+
description: 'A top directory to cache and restore'
6+
required: false
7+
default: '/home/ubuntu/.cache'
8+
path:
9+
description: 'A directory to cache and restore.'
610
required: true
7-
description: 'input description here'
8-
default: 'default value if applicable'
11+
key:
12+
description: 'An explicit key for a cache entry.'
13+
required: true
14+
outputs:
15+
cache-hit:
16+
description: 'Cache hit or not'
917
runs:
1018
using: 'node16'
11-
main: 'dist/index.js'
19+
main: 'dist/restore/index.js'
20+
post: 'dist/save/index.js'
21+
post-if: success()

dist/index.js.map

-1
This file was deleted.

0 commit comments

Comments
 (0)