Create SSH key file
This commit is contained in:
parent
3ada329e32
commit
8dc32f57e9
@ -5,6 +5,10 @@ inputs:
|
||||
description: 'The Gitea token to use for authentication'
|
||||
default: ${{ github.token }}
|
||||
required: false
|
||||
ssh-key:
|
||||
description: 'The SSH key to use for authentication'
|
||||
default: ${{ secrets.BRANCH_DEPLOY_KEY }}
|
||||
required: true
|
||||
outputs:
|
||||
url:
|
||||
description: 'The URL of the deployed branch'
|
||||
|
14
dist/index.js
vendored
14
dist/index.js
vendored
@ -42,6 +42,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__nccwpck_require__(7484));
|
||||
const gitea = __importStar(__nccwpck_require__(3228));
|
||||
const client = __importStar(__nccwpck_require__(8486));
|
||||
const exec = __importStar(__nccwpck_require__(5236));
|
||||
const fs = __importStar(__nccwpck_require__(9896));
|
||||
function main() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const branchName = gitea.context.ref;
|
||||
@ -54,7 +56,11 @@ function main() {
|
||||
core.info(`context.apiUrl: ${gitea.context.apiUrl}`);
|
||||
core.info('dumping process.env');
|
||||
Object.keys(process.env).forEach(key => {
|
||||
core.info(`process.env[${key}]`);
|
||||
let value = process.env[key];
|
||||
if (key.includes('TOKEN') || key.includes('SECRET') || key.includes('KEY')) {
|
||||
value = '***';
|
||||
}
|
||||
core.info(`process.env[${key}]=${value}`);
|
||||
});
|
||||
const api = client.default({
|
||||
baseUrl: gitea.context.apiUrl,
|
||||
@ -76,6 +82,12 @@ function main() {
|
||||
if (error) {
|
||||
core.error(`Error fetching repository: ${JSON.stringify(error)}`);
|
||||
}
|
||||
const sshKey = core.getInput('ssh-key', { required: true });
|
||||
core.info(`sshKey: ${sshKey.length}`);
|
||||
fs.writeFileSync('ssh_key', sshKey, { flag: 'w+', mode: "0600" });
|
||||
const result = yield exec.getExecOutput('cat', ['ssh_key']);
|
||||
const sshKeyContents = result.stdout;
|
||||
core.info(`sshKeyContents: ${sshKeyContents.length}`);
|
||||
});
|
||||
}
|
||||
main().catch(handleError);
|
||||
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -37,6 +37,7 @@
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
|
||||
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/io": "^1.0.1"
|
||||
}
|
||||
|
16
src/main.ts
16
src/main.ts
@ -2,6 +2,8 @@ import * as core from '@actions/core';
|
||||
import * as gitea from '@actions/github';
|
||||
import * as client from 'openapi-fetch';
|
||||
import * as specification from "./gitea-api";
|
||||
import * as exec from '@actions/exec';
|
||||
import * as fs from 'fs';
|
||||
|
||||
async function main() {
|
||||
const branchName = gitea.context.ref;
|
||||
@ -18,7 +20,11 @@ async function main() {
|
||||
|
||||
core.info('dumping process.env');
|
||||
Object.keys(process.env).forEach(key => {
|
||||
core.info(`process.env[${key}]`);
|
||||
let value = process.env[key];
|
||||
if (key.includes('TOKEN') || key.includes('SECRET') || key.includes('KEY')) {
|
||||
value = '***';
|
||||
}
|
||||
core.info(`process.env[${key}]=${value}`);
|
||||
});
|
||||
|
||||
const api = client.default<specification.paths>({
|
||||
@ -41,6 +47,14 @@ async function main() {
|
||||
if (error) {
|
||||
core.error(`Error fetching repository: ${JSON.stringify(error)}`);
|
||||
}
|
||||
|
||||
const sshKey = core.getInput('ssh-key', {required: true});
|
||||
core.info(`sshKey: ${sshKey.length}`);
|
||||
fs.writeFileSync('ssh_key', sshKey, {flag: 'w+', mode: "0600"});
|
||||
|
||||
const result = await exec.getExecOutput('cat', ['ssh_key']);
|
||||
const sshKeyContents = result.stdout;
|
||||
core.info(`sshKeyContents: ${sshKeyContents.length}`);
|
||||
}
|
||||
|
||||
main().catch(handleError);
|
||||
|
Loading…
x
Reference in New Issue
Block a user