Skip to content

Commit

Permalink
📝Update README.md(#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
7rikazhexde committed Nov 4, 2024
1 parent 52806a4 commit d88f350
Showing 1 changed file with 76 additions and 6 deletions.
82 changes: 76 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@

# JSON to Variables Setter

## Overview

**JSON to Variables Setter (json2vars-setter)** is a GitHub Action designed to parse a JSON file and set the resulting variables (such as operating systems, Python versions, and GitHub Pages branch) as outputs in a GitHub Actions workflow.
**JSON to Variables Setter (json2vars-setter)** is a GitHub Action designed to parse a JSON file and set the resulting variables (such as operating systems, programming language versions, and GitHub Pages branch) as outputs in a GitHub Actions workflow.

## Supported GitHub Actions Matrix Components

[![Python](https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white)](#example-workflow)
[![Node.js](https://img.shields.io/badge/Node.js-339933?style=for-the-badge&logo=node.js&logoColor=white)](.github/workflows/nodejs_test.yml)
[![Ruby](https://img.shields.io/badge/Ruby-CC342D?style=for-the-badge&logo=ruby&logoColor=white)](.github/workflows/ruby_test.yml)
[![Go](https://img.shields.io/badge/Go-00ADD8?style=for-the-badge&logo=go&logoColor=white)](.github/workflows/go_test.yml)
[![Rust](https://img.shields.io/badge/Rust-000000?style=for-the-badge&logo=rust&logoColor=white)](.github/workflows/rust_test.yml)

## Table of contents

- [JSON to Variables Setter](#json-to-variables-setter)
- [Overview](#overview)
- [Supported GitHub Actions Matrix Components](#supported-github-actions-matrix-components)
- [Table of contents](#table-of-contents)
- [Usage](#usage)
- [Inputs](#inputs)
- [Outputs](#outputs)
- [Example JSON File](#example-json-file)
- [Example Workflow](#example-workflow)
- [Language-specific Workflows](#language-specific-workflows)
- [License](#license)

## Usage
Expand All @@ -25,6 +34,7 @@ This action reads a JSON file (default path: `.github/workflows/matrix.json`) an
> - Please create the JSON file by referring to the [Example JSON File](#example-json-file).
> - By default, the JSON file path is `.github/workflows/matrix.json`. If you create a custom file, specify it in the `7rikazhexde/json2vars-setter` action.
> - In the workflow, only the variables specified in the Outputs section are available.
> - Language versions are optional. If a language is not defined in the JSON, its corresponding output will be empty.
### Inputs

Expand All @@ -35,19 +45,23 @@ This action reads a JSON file (default path: `.github/workflows/matrix.json`) an
### Outputs

> [!IMPORTANT]
> Please chack [Example Workflow](#example-workflow)\
> Please check [Example Workflow](#example-workflow).\
> (*1): In order to reference them in both steps and jobs, outputs must be specified.\
> (*2): For lists, explicitly enclose the list in "" to make it a string. (Note that it is not '').
| Input | Description |
| Output | Description |
|-------------------|----------------------------|
| `os` | List of operating systems |
| `versions_python` | List of Python versions |
| `versions_ruby` | List of Ruby versions |
| `versions_nodejs` | List of Node.js versions |
| `versions_go` | List of Go versions |
| `versions_rust` | List of Rust versions |
| `ghpages_branch` | GitHub Pages branch name |

## Example JSON File

Here is an example of a JSON file that can be used with this action
Here is an example of a JSON file that can be used with this action.

```json
{
Expand All @@ -61,15 +75,62 @@ Here is an example of a JSON file that can be used with this action
"3.10",
"3.11",
"3.12"
],
"ruby": [
"3.0.6",
"3.1.6",
"3.2.6"
],
"nodejs": [
"16",
"18",
"20",
"22"
],
"go": [
"1.23.0",
"1.23.1",
"1.23.2"
],
"rust": [
"1.79.0",
"1.80.0",
"1.81.0",
"1.82.0",
"stable"
]
},
"ghpages_branch": "ghgapes"
}
```

You can also define only specific languages.\
Undefined language versions will result in empty outputs(*3).

```jsonc
{
"os": [
"ubuntu-latest",
"windows-latest",
"macos-latest"
],
"versions": {
"python": [
"3.10",
"3.11",
"3.12"
]
//(*3)
},
"ghpages_branch": "ghgapes"
}
```

## Example Workflow

Below is an example of how to use the ***name: Set variables from JSON*** in a GitHub Actions workflow
Below is a **Python Example** of how to use the ***name: Set variables from JSON*** in a GitHub Actions workflow.

See [Language-specific Workflows](#language-specific-workflows) for workflow examples in other languages(**Node.js**, **Ruby**, **Go**, **Rust**).

```yaml
name: Test on PR by matrix.json (Except Dependabot)
Expand Down Expand Up @@ -155,6 +216,15 @@ jobs:
echo "${output}"
```
## Language-specific Workflows
For language-specific workflow examples, please refer to
- Node.js: [nodejs_test.yml](.github/workflows/nodejs_test.yml)
- Ruby: [ruby_test.yml](.github/workflows/ruby_test.yml)
- Go: [go_test.yml](.github/workflows/go_test.yml)
- Rust: [rust_test.yml](.github/workflows/rust_test.yml)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 comments on commit d88f350

Please sign in to comment.