Skip to content

Commit 9bae942

Browse files
author
zoeying
committed
props
0 parents  commit 9bae942

File tree

10 files changed

+696
-0
lines changed

10 files changed

+696
-0
lines changed

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "test"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
with:
13+
path: "./"
14+
15+
- name: get properties
16+
id: json_properties
17+
uses: ./
18+
with:
19+
file_path: 'package.json'
20+
21+
- run: |
22+
echo ${{steps.json_properties.outputs.name}}
23+
echo ${{steps.json_properties.outputs.version}}
24+
25+
- name: get specified property
26+
id: repository_type
27+
uses: ./
28+
with:
29+
file_path: 'package.json'
30+
prop_path: 'repository.type'
31+
32+
- run: |
33+
echo ${{steps.repository_type.outputs.value}}
34+

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
lerna-debug.log*
12+
13+
# OS metadata
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Ignore built ts files
18+
__tests__/runner/*
19+
lib/**/*
20+
!dist/**/*.js

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2021 zoexx
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# github-action-json-file-properties
2+
3+
Read JSON file and set properties to `output` of github action `steps`.
4+
5+
## Usage
6+
7+
Examples:
8+
9+
Get properties
10+
11+
```yaml
12+
---
13+
- name: get properties
14+
id: json_properties
15+
uses: ./
16+
with:
17+
file_path: "package.json"
18+
19+
- run: |
20+
echo ${{steps.json_properties.outputs.name}}
21+
echo ${{steps.json_properties.outputs.version}}
22+
```
23+
24+
Get a specified property **value** with `prop_path`
25+
26+
```yaml
27+
---
28+
- name: get specified property
29+
id: json_name
30+
uses: ./
31+
with:
32+
file_path: "package.json"
33+
prop_path: "repository.type"
34+
35+
- run: |
36+
echo ${{steps.get_json_nested_properties.outputs.value}}
37+
```

action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: "Get Properties From JSON File"
2+
description: "GitHub Action to load properties from a JSON file."
3+
author: "zoexx"
4+
inputs:
5+
file_path:
6+
required: true
7+
description: "path to file"
8+
prop_path:
9+
required: false
10+
description: "e.g.: key1.key2"
11+
runs:
12+
using: "node12"
13+
main: "dist/index.js"
14+
branding:
15+
color: "yellow"
16+
icon: "fast-forward"

0 commit comments

Comments
 (0)