Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
af6a5a4bc1 | |
|
|
8a9ce2ac2b | |
|
|
1fca7cb1f4 | |
|
|
a4f8f5e4e7 | |
|
|
986fa0612a | |
|
|
8823a4078b |
|
|
@ -1,6 +1,6 @@
|
||||||
# action-kubernetes-login
|
# 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
|
## Inputs
|
||||||
|
|
||||||
|
|
@ -13,8 +13,9 @@ This action prints "Hello World" or "Hello" + the name of a person to greet to t
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.1
|
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.6
|
||||||
with:
|
with:
|
||||||
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
||||||
|
configFileName: config
|
||||||
force: true
|
force: true
|
||||||
```
|
```
|
||||||
|
|
@ -4,7 +4,10 @@ inputs:
|
||||||
kubeconfig:
|
kubeconfig:
|
||||||
description: 'kubeconfig text'
|
description: 'kubeconfig text'
|
||||||
required: true
|
required: true
|
||||||
default: ''
|
configFileName:
|
||||||
|
description: 'config file name in $Home/.kube'
|
||||||
|
required: false
|
||||||
|
default: 'config'
|
||||||
force:
|
force:
|
||||||
description: 'force override'
|
description: 'force override'
|
||||||
required: false
|
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.
|
// 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 core = __nccwpck_require__(2186);
|
||||||
const { mkdir, writeFileSync, existsSync } = __nccwpck_require__(7147);
|
const { writeFileSync, existsSync, mkdirSync } = __nccwpck_require__(7147);
|
||||||
const os = __nccwpck_require__(2037);
|
const os = __nccwpck_require__(2037);
|
||||||
const path = __nccwpck_require__(1017);
|
const path = __nccwpck_require__(1017);
|
||||||
try {
|
try {
|
||||||
// `who-to-greet` input defined in action metadata file
|
// `who-to-greet` input defined in action metadata file
|
||||||
const kubeconfig = core.getInput('kubeconfig');
|
const kubeconfig = core.getInput('kubeconfig');
|
||||||
|
if(!kubeconfig){
|
||||||
|
throw {
|
||||||
|
message: "kubeconfig should not be empty"
|
||||||
|
}
|
||||||
|
}
|
||||||
const parentDir = path.join(os.homedir(),".kube")
|
const parentDir = path.join(os.homedir(),".kube")
|
||||||
mkdir(parentDir,{recursive:true})
|
mkdirSync(parentDir,{recursive:true})
|
||||||
const configFile = path.join(parentDir,"config")
|
const configFileName = core.getInput("configFileName")
|
||||||
|
const configFile = path.join(parentDir,configFileName)
|
||||||
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
||||||
throw {
|
throw {
|
||||||
message:".kube/config exists"
|
message:`.kube/${configFileName} exists`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
core.info(`write to ${configFile}`)
|
||||||
writeFileSync(configFile,kubeconfig)
|
writeFileSync(configFile,kubeconfig)
|
||||||
core.info(`save kubeconfig to ${configFile}`);
|
core.info(`save kubeconfig to ${configFile}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "action-kubernetes-login",
|
"name": "action-kubernetes-login",
|
||||||
"version": "0.0.0",
|
"version": "0.0.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "action-kubernetes-login",
|
"name": "action-kubernetes-login",
|
||||||
"version": "0.0.0",
|
"version": "0.0.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1"
|
"@actions/core": "^1.10.1"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "action-kubernetes-login",
|
"name": "action-kubernetes-login",
|
||||||
"version": "0.0.0",
|
"version": "0.0.5",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build src/index.js -o dist"
|
"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 core = require('@actions/core');
|
||||||
const { mkdir, writeFileSync, existsSync } = require('fs');
|
const { writeFileSync, existsSync, mkdirSync } = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
try {
|
try {
|
||||||
// `who-to-greet` input defined in action metadata file
|
// `who-to-greet` input defined in action metadata file
|
||||||
const kubeconfig = core.getInput('kubeconfig');
|
const kubeconfig = core.getInput('kubeconfig');
|
||||||
|
if(!kubeconfig){
|
||||||
|
throw {
|
||||||
|
message: "kubeconfig should not be empty"
|
||||||
|
}
|
||||||
|
}
|
||||||
const parentDir = path.join(os.homedir(),".kube")
|
const parentDir = path.join(os.homedir(),".kube")
|
||||||
mkdir(parentDir,{recursive:true})
|
mkdirSync(parentDir,{recursive:true})
|
||||||
const configFile = path.join(parentDir,"config")
|
const configFileName = core.getInput("configFileName")
|
||||||
|
const configFile = path.join(parentDir,configFileName)
|
||||||
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
||||||
throw {
|
throw {
|
||||||
message:".kube/config exists"
|
message:`.kube/${configFileName} exists`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
core.info(`write to ${configFile}`)
|
||||||
writeFileSync(configFile,kubeconfig)
|
writeFileSync(configFile,kubeconfig)
|
||||||
core.info(`save kubeconfig to ${configFile}`);
|
core.info(`save kubeconfig to ${configFile}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue