This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +37
-9
lines changed Expand file tree Collapse file tree 3 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -6,13 +6,31 @@ This GitHub Action creates a table in your `README.md`
6
6
7
7
### ` github-token ` [ REQUIRED]
8
8
9
- This can be achieved with
9
+ This is available in your GitHub Action
10
10
11
11
``` yaml
12
12
with :
13
13
github-token : ${{ secrets.GITHUB_TOKEN }}
14
14
` ` `
15
15
16
+ ### ` html-cell` [REQUIRED]
17
+
18
+ This is the html table cell content with `object-field-names`
19
+
20
+ ` ` ` yaml
21
+ with:
22
+ html-cell: '<td>{{ firstname }} {{ lastname }}</td>'
23
+ ` ` `
24
+
25
+ # ## `object-field-names` [REQUIRED]
26
+
27
+ This is json, and contains a list of the names of the fields in your json file data object
28
+
29
+ ` ` ` yaml
30
+ with:
31
+ object-field-names: '[ "firstname", "lastname" ]'
32
+ ` ` `
33
+
16
34
# ## `columns` [OPTIONAL]
17
35
18
36
**defaults to `2`**
Original file line number Diff line number Diff line change 9
9
description : ' json file to load'
10
10
required : true
11
11
default : ' data.json'
12
- github-token : # id of input
12
+ github-token :
13
13
description : ' github token'
14
14
required : true
15
+ html-cell :
16
+ description : ' html for the table cell'
17
+ required : true
18
+ object-field-names :
19
+ description : ' array of object field names from your json objects'
20
+ required : true
15
21
runs :
16
22
using : ' node12'
17
23
main : ' index.js'
Original file line number Diff line number Diff line change @@ -5,16 +5,20 @@ const path = require('path');
5
5
const readmeBox = require ( 'readme-box' ) . ReadmeBox ;
6
6
const chunk = require ( 'chunk' ) ;
7
7
8
- const generateCell = ( user ) => {
9
- return `<td align="center">
10
- <p><a href="https://github.com/${ user . githubUsername } ">${ user . name } </a></p>
11
- <img src="${ user . imageUrl } " />
12
- <p><a href="https://github.com/EddieJaoudeCommunity/awesome-github-profiles/issues/${ user . issueNumber } ">(:100: give your vote)</a></p>
13
- </td>` ;
8
+ const generateCell = ( cell ) => {
9
+ const objectFieldNames = JSON . parse ( core . getInput ( 'object-field-names' ) ) ;
10
+ let htmlCell = core . getInput ( 'html-cell' ) ;
11
+
12
+ objectFieldNames . forEach ( ( name ) => {
13
+ htmlCell = htmlCell . replace ( new RegExp ( `{{ ${ name } }}` ) , cell [ name ] ) ;
14
+ } ) ;
15
+ console . log ( objectFieldNames ) ;
16
+ console . log ( htmlCell ) ;
17
+ return htmlCell ;
14
18
}
15
19
16
20
const generateRow = ( columns , row ) => {
17
- const cells = row . map ( ( user ) => generateCell ( user ) ) ;
21
+ const cells = row . map ( ( cell ) => generateCell ( cell ) ) ;
18
22
19
23
if ( cells . length < columns ) {
20
24
cells . push ( '<td></td>' . repeat ( columns - cells . length ) ) ;
You can’t perform that action at this time.
0 commit comments