Skip to content

Commit d062b60

Browse files
authored
Merge pull request #20 from dominykas/post-install-steps
2 parents aa629c4 + 2c8cd74 commit d062b60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+19086
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.tmp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock=true
2+
shrinkwrap=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Dynamic action generator
2+
3+
description: Takes a list of steps as YAML inside string and writes them out as a composite action
4+
5+
runs:
6+
using: node12
7+
main: index.js
8+
9+
inputs:
10+
steps:
11+
description: "A string with an array of Github Actions steps"
12+
required: true
13+
path:
14+
description: "The name of the folder to write the action"
15+
required: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
'use strict';
2+
3+
process.on('unhandledRejection', (err) => {
4+
5+
throw err;
6+
});
7+
8+
9+
const ActionsCore = require('@actions/core');
10+
const Fs = require('fs');
11+
const Path = require('path');
12+
const Yaml = require('yaml');
13+
14+
15+
exports.main = function () {
16+
17+
const outputFolder = Path.join('.github', 'tmp', ActionsCore.getInput('path'));
18+
19+
Fs.mkdirSync(outputFolder, { recursive: true });
20+
21+
try {
22+
var steps = Yaml.parse(ActionsCore.getInput('steps'));
23+
}
24+
catch (err) {
25+
throw new Error('Invalid `steps` - unable to parse YAML.');
26+
}
27+
28+
if (!Array.isArray(steps)) {
29+
throw new Error('Invalid `steps` - not an array.');
30+
}
31+
32+
const action = {
33+
runs: {
34+
using: 'composite',
35+
steps
36+
}
37+
};
38+
39+
const actionYaml = Yaml.stringify(action);
40+
41+
const outputPath = Path.join(outputFolder, 'action.yaml');
42+
43+
console.log(`Writing ${outputPath}...`);
44+
console.log(actionYaml);
45+
Fs.writeFileSync(outputPath, actionYaml);
46+
};
47+
48+
49+
if (require.main === module) {
50+
exports.main();
51+
}

.github/actions/prepare-dynamic-steps/node_modules/.package-lock.json

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/prepare-dynamic-steps/node_modules/@actions/core/LICENSE.md

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)