Skip to content

Commit

Permalink
Added possibility to override
Browse files Browse the repository at this point in the history
  • Loading branch information
VitaliyLitovskyiSecurrency committed Jul 29, 2021
1 parent 7795d4e commit ec5aece
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.');
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit ec5aece

Please sign in to comment.