├── .github └── workflows │ ├── community.yml │ ├── release.yml │ └── stale.yml ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── action.yml ├── dist └── index.js ├── index.js ├── package-lock.json └── package.json /.github/workflows/community.yml: -------------------------------------------------------------------------------- 1 | on: 2 | fork: 3 | push: 4 | branches: [develop] 5 | issues: 6 | types: [opened] 7 | issue_comment: 8 | types: [created] 9 | pull_request_target: 10 | types: [opened] 11 | pull_request_review_comment: 12 | types: [created] 13 | 14 | jobs: 15 | welcome: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v1 19 | - uses: EddieHubCommunity/gh-action-community/src/welcome@main 20 | with: 21 | github-token: ${{ secrets.GITHUB_TOKEN }} 22 | issue-message: '

It''s great having you contribute to this project

Welcome to the community :nerd_face:' 23 | pr-message: '

It''s great having you contribute to this project

Welcome to the community :nerd_face:' 24 | footer: 'If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord Server and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.' 25 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Releases 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | changelog: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: conventional Changelog Action 15 | id: changelog 16 | uses: TriPSs/conventional-changelog-action@v5.3.0 17 | with: 18 | github-token: ${{ secrets.CHANGELOG_RELEASE }} 19 | 20 | - name: create release 21 | uses: actions/create-release@v1 22 | if: ${{ steps.changelog.outputs.skipped == 'false' }} 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.CHANGELOG_RELEASE }} 25 | with: 26 | tag_name: ${{ steps.changelog.outputs.tag }} 27 | release_name: ${{ steps.changelog.outputs.tag }} 28 | body: ${{ steps.changelog.outputs.clean_changelog }} 29 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: '30 1 * * *' 6 | 7 | jobs: 8 | stale: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/stale@v1 13 | with: 14 | repo-token: ${{ secrets.GITHUB_TOKEN }} 15 | stale-issue-message: 'Stale issue message' 16 | stale-pr-message: 'Stale pull request message' 17 | stale-issue-label: 'no-issue-activity' 18 | stale-pr-label: 'no-pr-activity' 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [1.2.0](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/compare/v0.1.1...v1.2.0) (2024-06-30) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * community action ([#22](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/22)) ([cc83c13](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/cc83c136b293a50e470d9940589e8dfeaa5bd7b3)) 7 | * **deps:** readme-box use official repo on default branch ([#16](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/16)) ([6d10b66](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/6d10b664997fa7d00d6e592b46be8a48800e6cf1)) 8 | * formatting ([#44](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/44)) ([f61e7a9](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/f61e7a93e2d5718f0eef5a447d07a8a12dc2cddd)) 9 | * node.js version ([#42](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/42)) ([b7d4498](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/b7d44982db865c6f74df2aa882745261a6158bf5)) 10 | * removed stats action ([7cf668f](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/7cf668f7f8114b82bf6d3fe2cd5eb2dce04f557d)) 11 | 12 | 13 | ### Features 14 | 15 | * **actions:** community and stale actions [#10](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/10) ([f80fdd4](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/f80fdd4009d9e1296b9191f20955bd2913af155f)) 16 | * customizable section name ([#40](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/40)) ([2eecb48](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/2eecb4824ae4b5244eac8d36fbd25c85174c36aa)) 17 | * file customizable ([#25](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/25)) ([2c89c88](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/2c89c88406c47f8dc6cbfccc18e71759ea51cae1)) 18 | * release workflow ([#46](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/46)) ([39b863a](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/39b863a3126c9455c6f4396faff75658d2a9368a)) 19 | 20 | 21 | 22 | ## [0.1.1](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/compare/914cc05b7e46c4e1911b1e3b64ac0b7d44c6e98c...v0.1.1) (2020-08-25) 23 | 24 | 25 | ### Bug Fixes 26 | 27 | * **action:** fix file paths ([c7e1caa](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/c7e1caa6e96d7b15eae8dc944ddd7219f154821a)) 28 | * **action:** fixed branch ref ([d3bf65e](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/d3bf65eb2c5f94f109af666d7087b9563eb13e6e)) 29 | * **action:** fixed typo ([246d7ba](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/246d7ba18928bd9a001e1ab3ab73a1ecf115931e)) 30 | * **action:** read file contents ([e07dee8](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/e07dee84b2a44978d52939f5c537be19b31d9d18)) 31 | * **action:** relative file path ([6dad09d](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/6dad09d8638d9ea646560e20c5a17924b5478dda)) 32 | * **action:** required variable name updated ([9a8e916](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/9a8e916292b22a6f4a94c318586a0459a9f336ad)) 33 | * **action:** trying to use branch ([63b4916](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/63b4916126b886320c1208a211482b8ef2e5ef81)) 34 | * **github:** use github token ([1db794f](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/1db794fa342f8d55ba83b3dd36edd8561268d8ef)) 35 | * **html:** columns var in row generation ([5499c6a](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/5499c6a232355afb959f0169c1ad56c541f6fbe1)) 36 | * **html:** convert array to string ([e1dd81f](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/e1dd81fc6434d540b4db4dd1b32c0723094df15f)) 37 | * **html:** table to display correctly ([ae31edf](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/ae31edfe897eb4eef82efd77a22efd5a7b77c3be)) 38 | * **json:** only strings allowed for inputs ([c74cedb](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/c74cedbd16f002e1ebe360bb2ff99bf3653cc3dd)) 39 | * **table:** cell repeated for replace [#2](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/2) ([a0abc27](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/a0abc2765ea11492da459cadf60c4561edf9ca4d)) 40 | * **table:** changed from const to let [#2](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/2) ([0f18229](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/0f182296db9f8f584ebd04ed5690475d35d9ed25)) 41 | * **table:** join not needed [#2](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/2) ([2d62d9f](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/2d62d9f2e770f1b20fea3a4046c51efd83c106b7)) 42 | * **write:** content should be a string ([1fe8665](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/1fe86657e1131e0bb753249e0a2d514e997bce0d)) 43 | * **write:** include lib, async function ([c2543d3](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/c2543d374810d13bd16b1cfb8475ec47014870e9)) 44 | * **write:** wrapped in async function ([f4b18b5](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/f4b18b56f3696291573a9be4bf514e1e82f038cd)) 45 | 46 | 47 | ### Features 48 | 49 | * **action:** inital action ([914cc05](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/914cc05b7e46c4e1911b1e3b64ac0b7d44c6e98c)) 50 | * **action:** read json data ([8a54e63](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/8a54e63fd414de139b4f335e13160b4989d38094)) 51 | * **action:** workspace path used ([7815faf](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/7815faf340579ade45ee00399ddd91c511607b3b)) 52 | * **columns:** column value via input ([c667710](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/c667710d56f443babe270dbfbc4beb290144090e)) 53 | * **columns:** multiple columns ([affa2f2](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/affa2f2c6d637a55b9e47c45bd1ba46adfed7c9d)) 54 | * **data:** reading the file from the branch ([e82fdaf](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/e82fdafc84d7344db1c21623a5ee4af8ddea085b)) 55 | * **debug:** more error output ([c8e0c85](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/c8e0c850e804efc09e5cb983feb80ef93a3aad43)) 56 | * **html:** boundary condition for cells ([3051550](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/305155059c296b96889bcb00ffd80107fefe0099)) 57 | * **html:** formatting json output as html ([7997ae3](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/7997ae3c26989ff6bf208129a27e4a64f6fa6e7d)) 58 | * **package:** using fork of readme-box ([ddbe87f](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/ddbe87fbef875b92ff85ad4fa1bfa9d9c90f0471)) 59 | * **package:** using fork of readme-box ([6a5fdbf](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/6a5fdbfe2a4ab74863c97edd19c13db88b63449a)) 60 | * **release:** meta data for gh actions [#6](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues/6) ([e20cf6e](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/e20cf6e4fd6c1fbb2f9320cb5bbdc442869a7ed2)) 61 | * **table:** customising the table html ([722d7be](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/722d7becf2b6a67b14b71e7a825913e45afc3766)) 62 | * **update:** replace readme with new content ([db43764](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/db437644ce5c9a5a7217422c69188a5815aa4946)) 63 | * **write:** update the readme with json ([322eb38](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/commit/322eb38ff9b9bec7b186e5397663a170a22cbd76)) 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, caste, color, religion, or sexual 10 | identity and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | - Demonstrating empathy and kindness toward other people 21 | - Being respectful of differing opinions, viewpoints, and experiences 22 | - Giving and gracefully accepting constructive feedback 23 | - Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | - Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | - The use of sexualized language or imagery, and sexual attention or advances of 31 | any kind 32 | - Trolling, insulting or derogatory comments, and personal or political attacks 33 | - Public or private harassment 34 | - Publishing others' private information, such as a physical or email address, 35 | without their explicit permission 36 | - Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Project Maintainers are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Project Maintainers have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported (this can be done anonymously) to the Project Maintainers responsible for enforcement at http://eddiejaoude.io/contact. 63 | All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All Project Maintainers are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Project Maintainers will follow these Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from Project Maintainers, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series of 85 | actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or permanent 92 | ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within the 112 | community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.1, available at 118 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 119 | 120 | Community Impact Guidelines were inspired by 121 | [Mozilla's code of conduct enforcement ladder][mozilla coc]. 122 | 123 | For answers to common questions about this code of conduct, see the FAQ at 124 | [https://www.contributor-covenant.org/faq][faq]. Translations are available at 125 | [https://www.contributor-covenant.org/translations][translations]. 126 | 127 | [homepage]: https://www.contributor-covenant.org 128 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 129 | [mozilla coc]: https://github.com/mozilla/diversity 130 | [faq]: https://www.contributor-covenant.org/faq 131 | [translations]: https://www.contributor-covenant.org/translations 132 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Eddie Jaoude Community 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Table generator 2 | 3 | This GitHub Action creates a html table in your `README.md` from a json file. 4 | 5 | ![Screenshot](https://user-images.githubusercontent.com/624760/91109172-0f905980-e672-11ea-8126-16276c821914.png) 6 | 7 | ## Inputs 8 | 9 | ### `github-token` [REQUIRED] 10 | 11 | This is available in your GitHub Action 12 | 13 | ```yaml 14 | with: 15 | github-token: ${{ secrets.GITHUB_TOKEN }} 16 | ``` 17 | 18 | ### `html-cell` [REQUIRED] 19 | 20 | This is the html table cell content with `object-field-names` 21 | 22 | ```yaml 23 | with: 24 | html-cell: '{{ firstname }} {{ lastname }}' 25 | ``` 26 | 27 | ### `object-field-names` [REQUIRED] 28 | 29 | This is json, and contains a list of the names of the fields in your json file data object 30 | 31 | ```yaml 32 | with: 33 | object-field-names: '[ "firstname", "lastname" ]' 34 | ``` 35 | 36 | ### `columns` [OPTIONAL] 37 | 38 | **defaults to `2`** 39 | 40 | ```yaml 41 | with: 42 | columns: 3 43 | ``` 44 | 45 | ### `json-file-path` [OPTIONAL] 46 | 47 | **defaults to `data.json`** 48 | 49 | ```yaml 50 | with: 51 | json-file-path: 'your-filename.json' 52 | ``` 53 | 54 | ### `file-to-use` [OPTIONAL] 55 | 56 | **Defaults to `README.md`** 57 | 58 | ```yaml 59 | with: 60 | file-to-use: 'README.md' 61 | ``` 62 | 63 | ### `section-name` [OPTIONAL] 64 | 65 | This allows you to change the `data-section` name in the comments to something else. 66 | This also allows multiple runs on the same file, for different sections. 67 | 68 | **defaults to `data-section`** 69 | 70 | ```yaml 71 | with: 72 | section-name: my-custom-section 73 | ``` 74 | 75 | ## Example usage 76 | 77 | Add `` and `` where you would like your table to appear in your README. 78 | 79 | ```yaml 80 | jobs: 81 | table: 82 | runs-on: ubuntu-latest 83 | name: Update README from json data 84 | steps: 85 | - uses: actions/checkout@v2 86 | - name: Read/Write data into README 87 | uses: eddiejaoude/github-actions-reader-writer@v0.1 88 | with: 89 | json-file-path: 'data.json' 90 | github-token: ${{ secrets.GITHUB_TOKEN }} 91 | columns: 3 92 | object-field-names: '[ "githubUsername", "name", "imageUrl", "issueNumber" ]' 93 | file-to-use: 'README.md' 94 | html-cell: '

{{ name }}

(:100: give your vote)

' 95 | ``` 96 | 97 | ### Json file 98 | 99 | ```typescript 100 | [ 101 | { 102 | "name": "Akas Rai", 103 | "githubUsername": "akasrai", 104 | "imageUrl": "https://user-images.githubusercontent.com/624760/88123456-d40df580-cbc2-11ea-9add-a7fc8675b243.png", 105 | "issueNumber": 12 106 | } 107 | ] 108 | ``` 109 | 110 | From this repository usage 111 | 112 | ## Our Pledge 113 | 114 | We take participation in our community as a harassment-free experience for everyone and we pledge to act in ways to contribute to an open, welcoming, diverse and inclusive community. 115 | 116 | If you have experienced or been made aware of unacceptable behaviour, please remember that you can report this. Read our [Code of Conduct](https://github.com/EddieHubCommunity/gh-actions-html-table-generator/blob/main/CODE_OF_CONDUCT.md). 117 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'json2table' 2 | description: 'json to html table' 3 | branding: 4 | icon: 'code' 5 | color: 'orange' 6 | inputs: 7 | columns: 8 | description: 'how many columns' 9 | required: false 10 | default: '2' 11 | json-file-path: 12 | description: 'json file to load' 13 | required: true 14 | default: 'data.json' 15 | github-token: 16 | description: 'github token' 17 | required: true 18 | html-cell: 19 | description: 'html for the table cell' 20 | required: true 21 | object-field-names: 22 | description: 'array of object field names from your json objects' 23 | required: true 24 | file-to-use: 25 | description: 'file to push the changes to' 26 | required: false 27 | default: 'README.md' 28 | section-name: 29 | description: 'section name to add the table to in the file' 30 | required: false 31 | default: 'data-section' 32 | runs: 33 | using: 'node20' 34 | main: 'dist/index.js' 35 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const github = require('@actions/github'); 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const readmeBox = require('readme-box').ReadmeBox; 6 | const chunk = require('chunk'); 7 | 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; 18 | } 19 | 20 | const generateRow = (columns, row) => { 21 | const cells = row.map((cell) => generateCell(cell)); 22 | 23 | if (cells.length < columns) { 24 | cells.push(''.repeat(columns - cells.length)); 25 | } 26 | 27 | return `${cells.join('')}`; 28 | }; 29 | 30 | (async () => { 31 | const githubToken = core.getInput('github-token'); 32 | const filePath = path.join(process.env.GITHUB_WORKSPACE, core.getInput('json-file-path')); 33 | const columns = core.getInput('columns'); 34 | const data = fs.readFileSync(filePath, 'utf8'); 35 | const json = JSON.parse(data); 36 | const fileToUsePath = core.getInput('file-to-use'); 37 | const sectionName = core.getInput('section-name'); 38 | 39 | try { 40 | const content = chunk(json, columns).map((row) => generateRow(columns, row)); 41 | const table = `${content.join('')}
`; 42 | 43 | await readmeBox.updateSection(table, { 44 | owner: process.env.GITHUB_REPOSITORY.split('/')[0], 45 | repo: process.env.GITHUB_REPOSITORY.split('/')[1], 46 | branch: process.env.GITHUB_REF.split('/')[2], 47 | token: githubToken, 48 | section: sectionName, 49 | path: fileToUsePath, 50 | }); 51 | } catch (error) { 52 | core.setFailed(JSON.stringify(error)); 53 | console.log(error); 54 | } 55 | })(); 56 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gh-actions-html-table-generator", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@actions/core": { 8 | "version": "1.2.4", 9 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.4.tgz", 10 | "integrity": "sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg==" 11 | }, 12 | "@actions/github": { 13 | "version": "4.0.0", 14 | "resolved": "https://registry.npmjs.org/@actions/github/-/github-4.0.0.tgz", 15 | "integrity": "sha512-Ej/Y2E+VV6sR9X7pWL5F3VgEWrABaT292DRqRU6R4hnQjPtC/zD3nagxVdXWiRQvYDh8kHXo7IDmG42eJ/dOMA==", 16 | "requires": { 17 | "@actions/http-client": "^1.0.8", 18 | "@octokit/core": "^3.0.0", 19 | "@octokit/plugin-paginate-rest": "^2.2.3", 20 | "@octokit/plugin-rest-endpoint-methods": "^4.0.0" 21 | } 22 | }, 23 | "@actions/http-client": { 24 | "version": "1.0.8", 25 | "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz", 26 | "integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==", 27 | "requires": { 28 | "tunnel": "0.0.6" 29 | } 30 | }, 31 | "@octokit/auth-token": { 32 | "version": "2.4.2", 33 | "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.2.tgz", 34 | "integrity": "sha512-jE/lE/IKIz2v1+/P0u4fJqv0kYwXOTujKemJMFr6FeopsxlIK3+wKDCJGnysg81XID5TgZQbIfuJ5J0lnTiuyQ==", 35 | "requires": { 36 | "@octokit/types": "^5.0.0" 37 | } 38 | }, 39 | "@octokit/core": { 40 | "version": "3.1.2", 41 | "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.1.2.tgz", 42 | "integrity": "sha512-AInOFULmwOa7+NFi9F8DlDkm5qtZVmDQayi7TUgChE3yeIGPq0Y+6cAEXPexQ3Ea+uZy66hKEazR7DJyU+4wfw==", 43 | "requires": { 44 | "@octokit/auth-token": "^2.4.0", 45 | "@octokit/graphql": "^4.3.1", 46 | "@octokit/request": "^5.4.0", 47 | "@octokit/types": "^5.0.0", 48 | "before-after-hook": "^2.1.0", 49 | "universal-user-agent": "^6.0.0" 50 | } 51 | }, 52 | "@octokit/endpoint": { 53 | "version": "6.0.5", 54 | "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.5.tgz", 55 | "integrity": "sha512-70K5u6zd45ItOny6aHQAsea8HHQjlQq85yqOMe+Aj8dkhN2qSJ9T+Q3YjUjEYfPRBcuUWNgMn62DQnP/4LAIiQ==", 56 | "requires": { 57 | "@octokit/types": "^5.0.0", 58 | "is-plain-object": "^4.0.0", 59 | "universal-user-agent": "^6.0.0" 60 | } 61 | }, 62 | "@octokit/graphql": { 63 | "version": "4.5.3", 64 | "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.5.3.tgz", 65 | "integrity": "sha512-JyYvi3j2tOb5ofASEpcg1Advs07H+Ag+I+ez7buuZfNVAmh1IYcDTuxd4gnYH8S2PSGu+f5IdDGxMmkK+5zsdA==", 66 | "requires": { 67 | "@octokit/request": "^5.3.0", 68 | "@octokit/types": "^5.0.0", 69 | "universal-user-agent": "^6.0.0" 70 | } 71 | }, 72 | "@octokit/openapi-types": { 73 | "version": "9.7.0", 74 | "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-9.7.0.tgz", 75 | "integrity": "sha512-TUJ16DJU8mekne6+KVcMV5g6g/rJlrnIKn7aALG9QrNpnEipFc1xjoarh0PKaAWf2Hf+HwthRKYt+9mCm5RsRg==" 76 | }, 77 | "@octokit/plugin-paginate-rest": { 78 | "version": "2.3.0", 79 | "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.3.0.tgz", 80 | "integrity": "sha512-Ye2ZJreP0ZlqJQz8fz+hXvrEAEYK4ay7br1eDpWzr6j76VXs/gKqxFcH8qRzkB3fo/2xh4Vy9VtGii4ZDc9qlA==", 81 | "requires": { 82 | "@octokit/types": "^5.2.0" 83 | } 84 | }, 85 | "@octokit/plugin-rest-endpoint-methods": { 86 | "version": "4.1.2", 87 | "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.1.2.tgz", 88 | "integrity": "sha512-PTI7wpbGEZ2IR87TVh+TNWaLcgX/RsZQalFbQCq8XxYUrQ36RHyERrHSNXFy5gkWpspUAOYRSV707JJv6BhqJA==", 89 | "requires": { 90 | "@octokit/types": "^5.1.1", 91 | "deprecation": "^2.3.1" 92 | } 93 | }, 94 | "@octokit/request": { 95 | "version": "5.4.7", 96 | "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.7.tgz", 97 | "integrity": "sha512-FN22xUDP0i0uF38YMbOfx6TotpcENP5W8yJM1e/LieGXn6IoRxDMnBf7tx5RKSW4xuUZ/1P04NFZy5iY3Rax1A==", 98 | "requires": { 99 | "@octokit/endpoint": "^6.0.1", 100 | "@octokit/request-error": "^2.0.0", 101 | "@octokit/types": "^5.0.0", 102 | "deprecation": "^2.0.0", 103 | "is-plain-object": "^4.0.0", 104 | "node-fetch": "^2.3.0", 105 | "once": "^1.4.0", 106 | "universal-user-agent": "^6.0.0" 107 | } 108 | }, 109 | "@octokit/request-error": { 110 | "version": "2.0.2", 111 | "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.2.tgz", 112 | "integrity": "sha512-2BrmnvVSV1MXQvEkrb9zwzP0wXFNbPJij922kYBTLIlIafukrGOb+ABBT2+c6wZiuyWDH1K1zmjGQ0toN/wMWw==", 113 | "requires": { 114 | "@octokit/types": "^5.0.1", 115 | "deprecation": "^2.0.0", 116 | "once": "^1.4.0" 117 | } 118 | }, 119 | "@octokit/types": { 120 | "version": "5.2.1", 121 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.2.1.tgz", 122 | "integrity": "sha512-PugtgEw8u++zAyBpDpSkR8K1OsT2l8QWp3ECL6bZHFoq9PfHDoKeGFWSuX2Z+Ghy93k1fkKf8tsmqNBv+8dEfQ==", 123 | "requires": { 124 | "@types/node": ">= 8" 125 | } 126 | }, 127 | "@types/node": { 128 | "version": "14.0.27", 129 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", 130 | "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==" 131 | }, 132 | "@vercel/ncc": { 133 | "version": "0.24.0", 134 | "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.24.0.tgz", 135 | "integrity": "sha512-crqItMcIwCkvdXY/V3/TzrHJQx6nbIaRqE1cOopJhgGX6izvNov40SmD//nS5flfEvdK54YGjwVVq+zG6crjOg==", 136 | "dev": true 137 | }, 138 | "before-after-hook": { 139 | "version": "2.1.0", 140 | "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.1.0.tgz", 141 | "integrity": "sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A==" 142 | }, 143 | "chunk": { 144 | "version": "0.0.2", 145 | "resolved": "https://registry.npmjs.org/chunk/-/chunk-0.0.2.tgz", 146 | "integrity": "sha1-BKpPMWZK6FDeUAz41XtfTCnNUi4=" 147 | }, 148 | "deprecation": { 149 | "version": "2.3.1", 150 | "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", 151 | "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" 152 | }, 153 | "is-plain-object": { 154 | "version": "4.1.1", 155 | "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-4.1.1.tgz", 156 | "integrity": "sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA==" 157 | }, 158 | "node-fetch": { 159 | "version": "2.6.0", 160 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", 161 | "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" 162 | }, 163 | "once": { 164 | "version": "1.4.0", 165 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 166 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 167 | "requires": { 168 | "wrappy": "1" 169 | } 170 | }, 171 | "readme-box": { 172 | "version": "git+https://git@github.com/Panquesito7/readme-box.git#610445321a1a698291c736b142eef426168de411", 173 | "from": "git+https://git@github.com/Panquesito7/readme-box.git#eddiehub", 174 | "requires": { 175 | "@actions/core": "^1.4.0", 176 | "@octokit/request": "^5.6.0" 177 | }, 178 | "dependencies": { 179 | "@actions/core": { 180 | "version": "1.4.0", 181 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz", 182 | "integrity": "sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg==" 183 | }, 184 | "@octokit/request": { 185 | "version": "5.6.1", 186 | "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.1.tgz", 187 | "integrity": "sha512-Ls2cfs1OfXaOKzkcxnqw5MR6drMA/zWX/LIS/p8Yjdz7QKTPQLMsB3R+OvoxE6XnXeXEE2X7xe4G4l4X0gRiKQ==", 188 | "requires": { 189 | "@octokit/endpoint": "^6.0.1", 190 | "@octokit/request-error": "^2.1.0", 191 | "@octokit/types": "^6.16.1", 192 | "is-plain-object": "^5.0.0", 193 | "node-fetch": "^2.6.1", 194 | "universal-user-agent": "^6.0.0" 195 | } 196 | }, 197 | "@octokit/request-error": { 198 | "version": "2.1.0", 199 | "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", 200 | "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", 201 | "requires": { 202 | "@octokit/types": "^6.0.3", 203 | "deprecation": "^2.0.0", 204 | "once": "^1.4.0" 205 | } 206 | }, 207 | "@octokit/types": { 208 | "version": "6.25.0", 209 | "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.25.0.tgz", 210 | "integrity": "sha512-bNvyQKfngvAd/08COlYIN54nRgxskmejgywodizQNyiKoXmWRAjKup2/LYwm+T9V0gsKH6tuld1gM0PzmOiB4Q==", 211 | "requires": { 212 | "@octokit/openapi-types": "^9.5.0" 213 | } 214 | }, 215 | "is-plain-object": { 216 | "version": "5.0.0", 217 | "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", 218 | "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" 219 | }, 220 | "node-fetch": { 221 | "version": "2.6.1", 222 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 223 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" 224 | } 225 | } 226 | }, 227 | "tunnel": { 228 | "version": "0.0.6", 229 | "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", 230 | "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" 231 | }, 232 | "universal-user-agent": { 233 | "version": "6.0.0", 234 | "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", 235 | "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" 236 | }, 237 | "wrappy": { 238 | "version": "1.0.2", 239 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 240 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gh-actions-html-table-generator", 3 | "version": "1.2.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "ncc build index.js -o dist", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/EddieHubCommunity/gh-actions-html-table-generator.git" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC", 17 | "bugs": { 18 | "url": "https://github.com/EddieHubCommunity/gh-actions-html-table-generator/issues" 19 | }, 20 | "homepage": "https://github.com/EddieHubCommunity/gh-actions-html-table-generator#readme", 21 | "dependencies": { 22 | "@actions/core": "^1.2.4", 23 | "@actions/github": "^4.0.0", 24 | "chunk": "0.0.2", 25 | "readme-box": "git+https://git@github.com/Panquesito7/readme-box.git#eddiehub" 26 | }, 27 | "devDependencies": { 28 | "@vercel/ncc": "^0.24.0" 29 | } 30 | } 31 | --------------------------------------------------------------------------------