Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Munkkeli committed Dec 16, 2024
0 parents commit 4c9b246
Show file tree
Hide file tree
Showing 295 changed files with 54,829 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Diploi Component Metadata Action

An action that collects component metadata from a Diploi stack.

[diploi.com](https://diploi.com/)
13 changes: 13 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Diploi Component Metadata Action'
description: 'An action that collects component metadata from a Diploi stack'
branding:
icon: 'package'
color: 'purple'

outputs:
components:
description: 'List of components (identifier, name, folder, stage, ref) that need to be built'

runs:
using: 'node20'
main: 'index.js'
37 changes: 37 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const core = require('@actions/core');

try {
const config = yaml.load(fs.readFileSync('diploi.yaml', 'utf-8'));
const componentsOutput = [];

for (const component of config.components) {
if (!fs.existsSync(component.identifier)) {
throw new Error(
`Folder /${component.identifier} for the ${component.identifier} component is missing.`
);
}

const componentOutput = {
identifier: component.identifier,
name: component.name || component.identifier,
folder: component.identifier,
ref: component.package.split('#').pop(),
};

componentsOutput.push(componentOutput);

if (fs.existsSync(path.join(component.identifier, 'Dockerfile.dev'))) {
componentsOutput.push({
...componentOutput,
stage: 'dev',
});
}
}

core.setOutput('components', JSON.stringify(componentsOutput));
} catch (error) {
core.setFailed(error.message);
}
1 change: 1 addition & 0 deletions node_modules/.bin/js-yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4c9b246

Please sign in to comment.