From ec5aece72a73ea7808e03ab63c96e9664c607eff Mon Sep 17 00:00:00 2001 From: Vitaliy Litovskyi Date: Thu, 29 Jul 2021 10:27:10 +0300 Subject: [PATCH] Added possibility to override --- README.md | 1 + action.yml | 3 +++ src/main.ts | 7 ++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c1d0f1..873c7e6 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ jobs: file it was generated from - `message` : specify the commit message for the commit of generated svg files (defaults to `Render PlantUML files`) +- `plant_uml_server_url` : specify custom plant uml server url (defaults to `http://www.plantuml.com/plantuml`) *env* diff --git a/action.yml b/action.yml index 8209b68..86a8390 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,9 @@ inputs: message: description: 'the commit message when committing generated images' default: 'Render PlantUML files' + plant_uml_server_url: + description: 'url for plant uml server' + default: 'http://www.plantuml.com/plantuml' runs: using: 'node12' main: 'dist/index.js' diff --git a/src/main.ts b/src/main.ts index 85902f6..782829b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,10 +8,10 @@ const plantumlEncoder = require('plantuml-encoder'); import { retrieveCodes, getCommitsFromPayload, updatedFiles } from './utils'; -async function generateSvg(code) { +async function generateSvg(code, plantUmlServerUrl) { const encoded = plantumlEncoder.encode(code); try { - const res = await axios.get(`http://www.plantuml.com/plantuml/svg/${encoded}`); + const res = await axios.get(`${plantUmlServerUrl}/svg/${encoded}`); return res.data; } catch(e) { // TODO @@ -20,6 +20,7 @@ async function generateSvg(code) { const diagramPath = core.getInput('path'); const commitMessage = core.getInput('message'); +const plantUmlServerUrl = core.getInput('plant_uml_server_url'); if (!process.env.GITHUB_TOKEN) { core.setFailed('Please set GITHUB_TOKEN env var.'); @@ -48,7 +49,7 @@ const octokit = new github.GitHub(process.env.GITHUB_TOKEN); ext: '.svg' }); - const svg = await generateSvg(plantumlCode.code); + const svg = await generateSvg(plantumlCode.code, plantUmlServerUrl); const blobRes = await octokit.git.createBlob({ owner, repo, content: Base64.encode(svg),