mirror of
https://github.com/papeloto/action-zip
synced 2024-11-22 05:29:35 -08:00
feat: project files
This commit is contained in:
parent
0ad34c7620
commit
a136662816
6 changed files with 4499 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules/
|
15
action.yml
Normal file
15
action.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
name: "Zip Files"
|
||||||
|
description: "Action for zipping files easily"
|
||||||
|
inputs:
|
||||||
|
github-token:
|
||||||
|
description: "GitHub Token"
|
||||||
|
required: true
|
||||||
|
files:
|
||||||
|
description: "Files or directories to zip"
|
||||||
|
required: true
|
||||||
|
files:
|
||||||
|
description: "Name of output zip file"
|
||||||
|
default: "result.zip"
|
||||||
|
runs:
|
||||||
|
using: "node12"
|
||||||
|
main: "dist/index.js"
|
2778
dist/index.js
vendored
Normal file
2778
dist/index.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
37
index.js
Normal file
37
index.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const AdmZip = require("adm-zip");
|
||||||
|
const core = require("@actions/core");
|
||||||
|
|
||||||
|
const inputFiles = core.getInput("files", { required: true });
|
||||||
|
const filename = core.getInput("filename");
|
||||||
|
|
||||||
|
const files = inputFiles.split(" ");
|
||||||
|
|
||||||
|
console.log(`Ready to zip "${inputFiles}" into ${filename}`);
|
||||||
|
|
||||||
|
const zip = new AdmZip();
|
||||||
|
|
||||||
|
files.forEach(file => {
|
||||||
|
if (!fs.existsSync(file)) {
|
||||||
|
console.log(` - ${file} (Not Found)`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dir = path.dirname(file);
|
||||||
|
const stats = fs.lstatSync(file);
|
||||||
|
|
||||||
|
if (stats.isDirectory()) {
|
||||||
|
zip.addLocalFolder(file, dir);
|
||||||
|
} else {
|
||||||
|
zip.addLocalFile(file, dir === "." ? "" : dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(` - ${file}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
zip.writeZip(filename);
|
||||||
|
|
||||||
|
console.log(`\nZipped file ${filename}`);
|
||||||
|
|
||||||
|
core.setOutput(filename);
|
38
package.json
Normal file
38
package.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"name": "action-zip",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Action for zipping files easily",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint .",
|
||||||
|
"build": "ncc build index.js -o dist",
|
||||||
|
"add": "git add dist/index.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/papeloto/action-version-files.git"
|
||||||
|
},
|
||||||
|
"author": "Victor Navarro <papeloto>",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/actions/action-version-files/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/actions/action-version-files#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/core": "^1.2.3",
|
||||||
|
"@actions/github": "^2.1.1",
|
||||||
|
"adm-zip": "^0.4.14",
|
||||||
|
"zip-local": "^0.3.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@zeit/ncc": "^0.21.1",
|
||||||
|
"eslint": "^6.8.0",
|
||||||
|
"husky": "^4.2.3",
|
||||||
|
"npm-run-all": "^4.1.5"
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "run-s lint build add"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue