Compare commits

...

6 Commits
0.0.1 ... main

Author SHA1 Message Date
moweilin af6a5a4bc1 添加configFileName配置 2024-01-18 17:55:44 +08:00
moweilin 8a9ce2ac2b 修改mkdir 2024-01-17 23:55:31 +08:00
moweilin 1fca7cb1f4 添加 core.info(`write to ${configFile}`) 2024-01-17 23:52:52 +08:00
moweilin a4f8f5e4e7 打印input 2024-01-17 23:47:32 +08:00
moweilin 986fa0612a save to 0.0.2 2024-01-17 23:42:12 +08:00
moweilin 8823a4078b change version 2024-01-17 22:49:07 +08:00
6 changed files with 32 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# action-kubernetes-login
This action prints "Hello World" or "Hello" + the name of a person to greet to the log.
This action create kubeconfig
## Inputs
@ -13,8 +13,9 @@ This action prints "Hello World" or "Hello" + the name of a person to greet to t
## Example usage
```yaml
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.1
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.6
with:
kubeconfig: ${{ secrets.KUBE_CONFIG }}
configFileName: config
force: true
```

View File

@ -4,7 +4,10 @@ inputs:
kubeconfig:
description: 'kubeconfig text'
required: true
default: ''
configFileName:
description: 'config file name in $Home/.kube'
required: false
default: 'config'
force:
description: 'force override'
required: false

15
dist/index.js vendored
View File

@ -26587,20 +26587,27 @@ var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const core = __nccwpck_require__(2186);
const { mkdir, writeFileSync, existsSync } = __nccwpck_require__(7147);
const { writeFileSync, existsSync, mkdirSync } = __nccwpck_require__(7147);
const os = __nccwpck_require__(2037);
const path = __nccwpck_require__(1017);
try {
// `who-to-greet` input defined in action metadata file
const kubeconfig = core.getInput('kubeconfig');
if(!kubeconfig){
throw {
message: "kubeconfig should not be empty"
}
}
const parentDir = path.join(os.homedir(),".kube")
mkdir(parentDir,{recursive:true})
const configFile = path.join(parentDir,"config")
mkdirSync(parentDir,{recursive:true})
const configFileName = core.getInput("configFileName")
const configFile = path.join(parentDir,configFileName)
if(existsSync(configFile) && !core.getBooleanInput("force")){
throw {
message:".kube/config exists"
message:`.kube/${configFileName} exists`
}
}
core.info(`write to ${configFile}`)
writeFileSync(configFile,kubeconfig)
core.info(`save kubeconfig to ${configFile}`);
} catch (error) {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "action-kubernetes-login",
"version": "0.0.0",
"version": "0.0.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "action-kubernetes-login",
"version": "0.0.0",
"version": "0.0.5",
"dependencies": {
"@actions/core": "^1.10.1"
},

View File

@ -1,6 +1,6 @@
{
"name": "action-kubernetes-login",
"version": "0.0.0",
"version": "0.0.5",
"type": "commonjs",
"scripts": {
"build": "ncc build src/index.js -o dist"

View File

@ -1,18 +1,25 @@
const core = require('@actions/core');
const { mkdir, writeFileSync, existsSync } = require('fs');
const { writeFileSync, existsSync, mkdirSync } = require('fs');
const os = require('os');
const path = require('path');
try {
// `who-to-greet` input defined in action metadata file
const kubeconfig = core.getInput('kubeconfig');
if(!kubeconfig){
throw {
message: "kubeconfig should not be empty"
}
}
const parentDir = path.join(os.homedir(),".kube")
mkdir(parentDir,{recursive:true})
const configFile = path.join(parentDir,"config")
mkdirSync(parentDir,{recursive:true})
const configFileName = core.getInput("configFileName")
const configFile = path.join(parentDir,configFileName)
if(existsSync(configFile) && !core.getBooleanInput("force")){
throw {
message:".kube/config exists"
message:`.kube/${configFileName} exists`
}
}
core.info(`write to ${configFile}`)
writeFileSync(configFile,kubeconfig)
core.info(`save kubeconfig to ${configFile}`);
} catch (error) {