Skip to content

Commit

Permalink
add json-to-ouput action
Browse files Browse the repository at this point in the history
  • Loading branch information
pngwn committed Aug 2, 2024
1 parent b522cdb commit 8052b02
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/json-to-output/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Convert a json file to outputs"

inputs:
path:
description: "Path to the json file"
required: true

runs:
using: "node20"
main: "dist/index.js"
20 changes: 20 additions & 0 deletions packages/json-to-output/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { getInput, setOutput } from "@actions/core";
import { context, getOctokit } from "@actions/github";
import { readFileSync } from "fs";
import { join } from "path";

async function run() {
const path = getInput("path");

const full_path = join(process.cwd(), path);

const content = readFileSync(full_path, "utf-8");

const json = JSON.parse(content);

for (const key in json) {
setOutput(key, json[key]);
}
}

run();
14 changes: 14 additions & 0 deletions packages/json-to-output/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@gradio-action/json-to-output",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"dependencies": {}
}

0 comments on commit 8052b02

Please sign in to comment.