1
0
Fork 0
mirror of https://github.com/shimataro/ssh-key-action.git synced 2025-06-19 22:52:10 +10:00

Merge pull request #12 from shimataro/development

release v1.1.0
This commit is contained in:
shimataro 2019-09-19 07:25:58 +09:00 committed by GitHub
commit 34e71225c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 657 additions and 522 deletions

37
.editorconfig Normal file
View file

@ -0,0 +1,37 @@
# http://editorconfig.org/
# https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
root = true
# recommended settings; DO NOT CHANGE!
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
# common settings
[*]
indent_style = tab
indent_size = 4
tab_width = 4
max_line_length = off
quote_type = double
curly_bracket_next_line = true
spaces_around_operators = true
spaces_around_brackets = none
indent_brace_style = allman
# JSON/YAML
[*.{json,babelrc,code-workspace,yml,yaml}]
indent_style = space
indent_size = 2
tab_width = 2
# markdown
[*.md]
indent_style = space

32
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,32 @@
# https://help.github.com/ja/articles/workflow-syntax-for-github-actions
on:
push:
branches:
- master
- develop
pull_request:
name: Build
jobs:
build:
name: Build on ${{ matrix.platform }} / Node.js v${{ matrix.nodejs }}
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform:
- "Windows-latest"
- "macOS-latest"
- "Ubuntu-latest"
nodejs:
- 12
steps:
- name: Turn off auto-crlf
run: git config --global core.autocrlf false
- name: Checkout source codes
uses: actions/checkout@v1
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.nodejs }}
- name: Build
run: npm run build

View file

@ -7,9 +7,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased] ## [Unreleased]
## [1.1.0]
### Others
* Support Visual Studio Code officially.
* Use GitHub Actions for build test.
## [1.0.0] ## [1.0.0]
* First release. * First release.
[Unreleased]: https://github.com/shimataro/ssh-key-action/compare/v1.0.0...HEAD [Unreleased]: https://github.com/shimataro/ssh-key-action/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/shimataro/ssh-key-action/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/shimataro/ssh-key-action/compare/8deacc95b1ee5732107e56baa4c8aac4c386ef7e...v1.0.0 [1.0.0]: https://github.com/shimataro/ssh-key-action/compare/8deacc95b1ee5732107e56baa4c8aac4c386ef7e...v1.0.0

View file

@ -1,5 +1,9 @@
# Install SSH key # Install SSH key
[![Build][image-build]][link-build]
[![Release][image-release]][link-release]
[![License][image-license]][link-license]
This action installs SSH key into `~/.ssh`. This action installs SSH key into `~/.ssh`.
Useful for `rsync` over SSH in deployment script. Useful for `rsync` over SSH in deployment script.
@ -16,7 +20,7 @@ steps:
with: with:
private-key: ${{ secret.SSH_KEY }} private-key: ${{ secret.SSH_KEY }}
public-key: ${{ secret.SSH_KEY_PUBLIC }} public-key: ${{ secret.SSH_KEY_PUBLIC }}
name: 'id_rsa' # optional name: id_rsa # optional
- name: Install packages - name: Install packages
run: apt install openssh-client rsync run: apt install openssh-client rsync
- name: rsync over ssh - name: rsync over ssh
@ -28,3 +32,14 @@ See [Workflow syntax for GitHub Actions](https://help.github.com/en/articles/wor
## License ## License
The scripts and documentation in this project are released under the [MIT License](LICENSE) The scripts and documentation in this project are released under the [MIT License](LICENSE)
## Changelog
See [CHANGELOG.md](CHANGELOG.md).
[image-build]: https://github.com/shimataro/ssh-key-action/workflows/Build/badge.svg
[link-build]: https://github.com/shimataro/ssh-key-action
[image-release]: https://img.shields.io/github/release/shimataro/ssh-key-action.svg
[link-release]: https://github.com/shimataro/ssh-key-action/releases
[image-license]: https://img.shields.io/github/license/shimataro/ssh-key-action.svg
[link-license]: ./LICENSE

View file

@ -1,19 +1,19 @@
name: 'Install SSH Key' name: "Install SSH Key"
description: 'Install SSH key to ~/.ssh' description: "Install SSH key to ~/.ssh"
author: 'shimataro' author: "shimataro"
branding: branding:
icon: 'terminal' icon: "terminal"
color: 'gray-dark' color: "gray-dark"
inputs: inputs:
private-key: private-key:
description: 'private SSH key' description: "private SSH key"
required: true required: true
public-key: public-key:
description: 'public SSH key' description: "public SSH key"
required: true required: true
name: name:
description: 'SSH key file name (default: id_rsa)' description: "SSH key file name (default: id_rsa)"
default: 'id_rsa' default: "id_rsa"
runs: runs:
using: 'node12' using: "node12"
main: 'lib/main.js' main: "lib/main.js"

View file

@ -10,6 +10,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
/**
* main function
*/
function main() { function main() {
try { try {
const home = getHomeDirectory(); const home = getHomeDirectory();
@ -18,10 +21,10 @@ function main() {
recursive: true, recursive: true,
mode: 0o700, mode: 0o700,
}); });
const privateKey = core.getInput('private-key'); const privateKey = core.getInput("private-key");
const publicKey = core.getInput('public-key'); const publicKey = core.getInput("public-key");
const name = core.getInput('name'); const name = core.getInput("name");
const fileName = path.resolve(dirName, name); const fileName = path.join(dirName, name);
fs.writeFileSync(fileName, privateKey, { fs.writeFileSync(fileName, privateKey, {
mode: 0o400, mode: 0o400,
}); });
@ -39,10 +42,10 @@ function main() {
* @returns home directory * @returns home directory
*/ */
function getHomeDirectory() { function getHomeDirectory() {
const home_env = process.platform == "win32" ? "USERPROFILE" : "HOME"; const homeEnv = process.platform == "win32" ? "USERPROFILE" : "HOME";
const home = process.env[home_env]; const home = process.env[homeEnv];
if (home === undefined) { if (home === undefined) {
throw new Error(`${home_env} is not defined`); throw new Error(`${homeEnv} is not defined`);
} }
return home; return home;
} }

View file

@ -1 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,oDAAsC;AAEtC,SAAS,IAAI;IAET,IACA;QACI,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAC;QAChC,MAAM,OAAO,GA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AAI,KAAK,SAAS,EACrB;QACC,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,iBAAiB,CAAC,CAAC;KAC7C;IAED,OAAO,IAAI,CAAC;AACb,CAAC;AAED,IAAI,EAAE,CAAC"}

View file

@ -1,7 +0,0 @@
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -20,7 +20,7 @@ function issue(name, message = '') {
issueCommand(name, {}, message); issueCommand(name, {}, message);
} }
exports.issue = issue; exports.issue = issue;
const CMD_PREFIX = '##['; const CMD_STRING = '::';
class Command { class Command {
constructor(command, properties, message) { constructor(command, properties, message) {
if (!command) { if (!command) {
@ -31,7 +31,7 @@ class Command {
this.message = message; this.message = message;
} }
toString() { toString() {
let cmdStr = CMD_PREFIX + this.command; let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
for (const key in this.properties) { for (const key in this.properties) {
@ -40,12 +40,12 @@ class Command {
if (val) { if (val) {
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)};`; cmdStr += `${key}=${escape(`${val || ''}`)},`;
} }
} }
} }
} }
cmdStr += ']'; cmdStr += CMD_STRING;
// safely append the message - avoid blowing up when attempting to // safely append the message - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
const message = `${this.message || ''}`; const message = `${this.message || ''}`;

View file

@ -1 +1 @@
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC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UAAU,CAAA;QAEpB,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}

View file

@ -71,6 +71,11 @@ export declare function error(message: string): void;
* @param message warning issue message * @param message warning issue message
*/ */
export declare function warning(message: string): void; export declare function warning(message: string): void;
/**
* Writes info to log with console.log.
* @param message info message
*/
export declare function info(message: string): void;
/** /**
* Begin an output group. * Begin an output group.
* *

View file

@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("./command"); const command_1 = require("./command");
const os = require("os");
const path = require("path"); const path = require("path");
/** /**
* The code to exit an action * The code to exit an action
@ -68,7 +69,7 @@ exports.addPath = addPath;
* @returns string * @returns string
*/ */
function getInput(name, options) { function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || ''; const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (options && options.required && !val) { if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`); throw new Error(`Input required and not supplied: ${name}`);
} }
@ -125,6 +126,14 @@ function warning(message) {
command_1.issue('warning', message); command_1.issue('warning', message);
} }
exports.warning = warning; exports.warning = warning;
/**
* Writes info to log with console.log.
* @param message info message
*/
function info(message) {
process.stdout.write(message + os.EOL);
}
exports.info = info;
/** /**
* Begin an output group. * Begin an output group.
* *

View file

@ -1 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,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,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}

View file

@ -1,28 +1,28 @@
{ {
"_from": "@actions/core@1.1.0", "_from": "@actions/core@1.1.1",
"_id": "@actions/core@1.1.0", "_id": "@actions/core@1.1.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==", "_integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==",
"_location": "/@actions/core", "_location": "/@actions/core",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "version",
"registry": true, "registry": true,
"raw": "@actions/core@1.1.0", "raw": "@actions/core@1.1.1",
"name": "@actions/core", "name": "@actions/core",
"escapedName": "@actions%2fcore", "escapedName": "@actions%2fcore",
"scope": "@actions", "scope": "@actions",
"rawSpec": "1.1.0", "rawSpec": "1.1.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "1.1.0" "fetchSpec": "1.1.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/", "/",
"/@actions/tool-cache" "/@actions/tool-cache"
], ],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"_shasum": "25c3aff43a20f9c5a04e2a3439898a49ba8d3625", "_shasum": "e08f3dbfe04721bb3d040f8fca2d6d7e1817b2e1",
"_spec": "@actions/core@1.1.0", "_spec": "@actions/core@1.1.1",
"_where": "/home/shimataro/projects/actions/ssh-key-action", "_where": "/home/shimataro/projects/actions/ssh-key-action",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
@ -40,7 +40,6 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core", "homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
"keywords": [ "keywords": [
"github", "github",
@ -61,5 +60,5 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.1.0" "version": "1.1.1"
} }

10
package-lock.json generated
View file

@ -1,13 +1,13 @@
{ {
"name": "action-install-ssh-key", "name": "ssh-key-action",
"version": "1.0.0", "version": "1.1.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.1.0", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.0.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"integrity": "sha512-KKpo3xzo0Zsikni9tbOsEQkxZBGDsYSJZNkTvmo0gPSXrc98TBOcdTvKwwjitjkjHkreTggWdB1ACiAFVgsuzA==" "integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg=="
}, },
"@actions/exec": { "@actions/exec": {
"version": "1.0.1", "version": "1.0.1",

View file

@ -1,8 +1,8 @@
{ {
"name": "action-install-ssh-key", "name": "ssh-key-action",
"version": "1.0.0", "version": "1.1.0",
"private": true, "private": true,
"description": "Install SSH key to .ssh for GitHub Actions", "description": "Install SSH key to .ssh",
"main": "lib/main.js", "main": "lib/main.js",
"engines": { "engines": {
"node": ">= 8.0.0", "node": ">= 8.0.0",
@ -14,7 +14,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/shimataro/action-install-ssh-key.git" "url": "git+https://github.com/shimataro/ssh-key-action.git"
}, },
"keywords": [ "keywords": [
"actions", "actions",
@ -26,7 +26,7 @@
"author": "shimataro", "author": "shimataro",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "1.1.0", "@actions/core": "1.1.1",
"@actions/github": "1.1.0", "@actions/github": "1.1.0",
"@actions/io": "1.0.1", "@actions/io": "1.0.1",
"@actions/tool-cache": "1.1.1" "@actions/tool-cache": "1.1.1"

View file

@ -1,37 +1,40 @@
import * as fs from "fs"; import * as fs from "fs";
import * as path from 'path'; import * as path from "path";
import * as core from '@actions/core'; import * as core from "@actions/core";
/**
* main function
*/
function main(): void function main(): void
{ {
try try
{ {
const home = getHomeDirectory(); const home = getHomeDirectory();
const dirName = path.resolve(home, ".ssh"); const dirName = path.resolve(home, ".ssh");
fs.mkdirSync(dirName, { fs.mkdirSync(dirName, {
recursive: true, recursive: true,
mode: 0o700, mode: 0o700,
}); });
const privateKey = core.getInput('private-key') as string; const privateKey = core.getInput("private-key") as string;
const publicKey = core.getInput('public-key') as string; const publicKey = core.getInput("public-key") as string;
const name = core.getInput('name') as string; const name = core.getInput("name") as string;
const fileName = path.resolve(dirName, name); const fileName = path.join(dirName, name);
fs.writeFileSync(fileName, privateKey, { fs.writeFileSync(fileName, privateKey, {
mode: 0o400, mode: 0o400,
}); });
fs.writeFileSync(`${fileName}.pub`, publicKey, { fs.writeFileSync(`${fileName}.pub`, publicKey, {
mode: 0o444, mode: 0o444,
}); });
console.log(`SSH key has been stored to ${fileName} successfully.`); console.log(`SSH key has been stored to ${fileName} successfully.`);
} }
catch(err) catch(err)
{ {
core.setFailed(err.message); core.setFailed(err.message);
} }
} }
/** /**
@ -40,14 +43,14 @@ function main(): void
*/ */
function getHomeDirectory(): string function getHomeDirectory(): string
{ {
const home_env = process.platform == "win32" ? "USERPROFILE" : "HOME"; const homeEnv = process.platform == "win32" ? "USERPROFILE" : "HOME";
const home = process.env[home_env]; const home = process.env[homeEnv];
if(home === undefined) if(home === undefined)
{ {
throw new Error(`${home_env} is not defined`); throw new Error(`${homeEnv} is not defined`);
} }
return home; return home;
} }
main(); main();

View file

@ -0,0 +1,31 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"eslint.enable": true,
"json.format.enable": true,
"typescript.format.enable": true,
"typescript.format.insertSpaceAfterCommaDelimiter": true,
"typescript.format.insertSpaceAfterConstructor": false,
"typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": false,
"typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
"typescript.format.insertSpaceAfterSemicolonInForStatements": true,
"typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": false,
"typescript.format.placeOpenBraceOnNewLineForFunctions": true,
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"typescript.validate.enable": true
},
"extensions": {
"recommendations": [
"EditorConfig.EditorConfig",
"eg2.vscode-npm-script"
]
}
}