Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
af6a5a4bc1 | |
|
|
8a9ce2ac2b | |
|
|
1fca7cb1f4 | |
|
|
a4f8f5e4e7 | |
|
|
986fa0612a | |
|
|
8823a4078b |
|
|
@ -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
|
||||
```
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
15
src/index.js
15
src/index.js
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue