Skip to content

Commit

Permalink
New try with a store of artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Demmonius committed Jan 7, 2021
1 parent e2e8a5a commit fdf8c93
Show file tree
Hide file tree
Showing 242 changed files with 40,882 additions and 117 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
delimiter:
description: 'Parsing split character'
required: false
default: ','
default: '\n'
outputs:
variablesObject:
description: 'Object containing values keys and values'
Expand Down
7 changes: 6 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BUILD_MAIN_FILENAME = exports.BUILD_DIR = void 0;
exports.WORKDIR = exports.BUILD_MAIN_FILENAME = exports.BUILD_DIR = void 0;
const path_1 = require("path");
/**
* Directory where the compiled version (JS) of the TS code is stored.
*
Expand All @@ -13,3 +14,7 @@ exports.BUILD_DIR = 'lib';
* XXX Should match the package.json:main value.
*/
exports.BUILD_MAIN_FILENAME = 'main.js';
/**
* Artifact directory containing variables artifacts
*/
exports.WORKDIR = path_1.join(process.cwd(), '_store-variables');
42 changes: 39 additions & 3 deletions lib/manageArtifacts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const artifact_1 = __importDefault(require("@actions/artifact"));
const path_1 = require("path");
const fs_1 = require("fs");
const rimraf_1 = __importDefault(require("rimraf"));
const config_1 = require("./config");
const defineVariableOperation = (variable) => {
try {
const variableContent = {
Expand All @@ -26,7 +43,25 @@ const defineVariableOperation = (variable) => {
throw Error('Error type');
}
};
const manageArtifacts = (variables, delimiter) => {
const storeArtifact = (variables) => __awaiter(void 0, void 0, void 0, function* () {
const client = artifact_1.default.create();
const artifactOptions = {
retentionDays: 1 // Only keep artifacts 1 day to avoid reach limit: https://github.com/actions/toolkit/blob/c861dd8859fe5294289fcada363ce9bc71e9d260/packages/artifact/src/internal/upload-options.ts#L1
};
const artifactsUploadPromises = [];
console.log(variables);
for (const variable of variables) {
const file = path_1.join(config_1.WORKDIR, `${variable.key}.txt`);
// cleanup old directories if needed
rimraf_1.default.sync(config_1.WORKDIR);
fs_1.mkdirSync(config_1.WORKDIR);
fs_1.writeFileSync(file, variable.value, { encoding: 'utf8' });
artifactsUploadPromises.push(client.uploadArtifact(variable.value, [file], process.cwd(), artifactOptions));
}
const uploadResponses = yield Promise.all(artifactsUploadPromises);
console.log(uploadResponses);
});
const manageArtifacts = (variables, delimiter) => __awaiter(void 0, void 0, void 0, function* () {
const variablesDetail = [];
for (const variable of variables.split(delimiter)) {
try {
Expand All @@ -36,6 +71,7 @@ const manageArtifacts = (variables, delimiter) => {
console.log(error);
}
}
console.log(variablesDetail);
};
yield storeArtifact(variablesDetail.filter((variable) => variable.operationToProceed === 0)
.map((variable) => variable.variableDetail));
});
exports.default = manageArtifacts;
2 changes: 1 addition & 1 deletion node_modules/.bin/rimraf

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

15 changes: 15 additions & 0 deletions node_modules/.yarn-integrity

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/artifact/LICENSE.md

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

Loading

0 comments on commit fdf8c93

Please sign in to comment.