Skip to content

Commit 26d1612

Browse files
committed
Initial commit
1 parent 27dbab8 commit 26d1612

File tree

12 files changed

+2571
-311
lines changed

12 files changed

+2571
-311
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v3
15+
with:
16+
node-version: '16'
17+
cache: 'yarn'
1418
- run: |
1519
yarn
1620
- run: |
1721
yarn all
18-
test: # make sure the action works on a clean machine without building
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v2
22-
- uses: ./
23-
with:
24-
milliseconds: 1000

README.md

Lines changed: 18 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,24 @@
1-
# Create a JavaScript Action using TypeScript
1+
# JSON array values prefixer
22

3-
Use this template to bootstrap the creation of a TypeScript action.:rocket:
3+
Prefix all values of a JSON array
44

5-
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance.
5+
See [action.yml](./action.yml) for the list of `inputs` and `outputs`.
66

7-
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action)
8-
9-
## Create an action from this template
10-
11-
Click the `Use this Template` and provide the new repo details for your action
12-
13-
## Code in Main
14-
15-
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance.
16-
17-
Install the dependencies
18-
```bash
19-
$ yarn install
20-
```
21-
22-
Build the typescript and package it for distribution
23-
```bash
24-
$ yarn build && yarn package
25-
```
26-
27-
Run the tests :heavy_check_mark:
28-
```bash
29-
$ yarn test
30-
31-
PASS ./index.test.js
32-
✓ throws invalid number (3ms)
33-
wait 500 ms (504ms)
34-
test runs (95ms)
35-
36-
...
37-
```
38-
39-
## Change action.yml
40-
41-
The action.yml contains defines the inputs and output for your action.
42-
43-
Update the action.yml with your name, description, inputs and outputs for your action.
44-
45-
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
46-
47-
## Change the Code
48-
49-
Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
50-
51-
```javascript
52-
import * as core from '@actions/core';
53-
...
54-
55-
async function run() {
56-
try {
57-
...
58-
}
59-
catch (error) {
60-
core.setFailed(error.message);
61-
}
62-
}
63-
64-
run()
65-
```
66-
67-
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
68-
69-
## Publish to a distribution branch
70-
71-
Actions are run from GitHub repos so we will checkin the packed dist folder.
72-
73-
Then run [ncc](https://github.com/zeit/ncc) and push the results:
74-
```bash
75-
$ yarn package
76-
$ git add dist
77-
$ git commit -a -m "prod dependencies"
78-
$ git push origin releases/v1
79-
```
80-
81-
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.
82-
83-
Your action is now published! :rocket:
84-
85-
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
86-
87-
## Validate
88-
89-
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml))
7+
## Example usage
908

919
```yaml
92-
uses: ./
93-
with:
94-
milliseconds: 1000
10+
prefix-secrets:
11+
name: Format secrets
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v2
16+
17+
- name: Format secrets
18+
id: task-definition
19+
uses: agendrix/[email protected]
20+
with:
21+
file_path: secrets/app.json
22+
key: key
23+
prefix: prefix
9524
```
96-
97-
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket:
98-
99-
## Usage:
100-
101-
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
102-
103-
## Helpers
104-
105-
If you created helpers that you consider could benefit to other actions, please consider contributing by adding them to the `helpers` folder.

__tests__/main.test.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

action.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
name: 'Your name here'
2-
description: 'Provide a description here'
3-
author: 'Your name or organization here'
1+
name: JSON values prefixer
2+
description: Prefix all values of a JSON array
43
inputs:
5-
milliseconds: # change this
4+
file_path:
5+
description: The JSON file path
66
required: true
7-
description: 'input description here'
8-
default: 'default value if applicable'
7+
prefix:
8+
description: The prefix
9+
required: true
10+
key:
11+
description: |
12+
Prefix all values corresponding the a certain key.
13+
Can be used if your JSON array contains objects.
14+
required: false
915
runs:
10-
using: 'node12'
11-
main: 'dist/index.js'
16+
using: node16
17+
main: dist/index.js

0 commit comments

Comments
 (0)