Compare commits
No commits in common. "main" and "0.0.1" have entirely different histories.
|
|
@ -1,6 +1,6 @@
|
||||||
# action-kubernetes-login
|
# action-kubernetes-login
|
||||||
|
|
||||||
This action create kubeconfig
|
This action prints "Hello World" or "Hello" + the name of a person to greet to the log.
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
|
|
@ -13,9 +13,8 @@ This action create kubeconfig
|
||||||
## Example usage
|
## Example usage
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.6
|
uses: git.qtoa.cn/actions/action-kubernetes-login@0.0.1
|
||||||
with:
|
with:
|
||||||
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
||||||
configFileName: config
|
|
||||||
force: true
|
force: true
|
||||||
```
|
```
|
||||||
|
|
@ -4,10 +4,7 @@ inputs:
|
||||||
kubeconfig:
|
kubeconfig:
|
||||||
description: 'kubeconfig text'
|
description: 'kubeconfig text'
|
||||||
required: true
|
required: true
|
||||||
configFileName:
|
default: ''
|
||||||
description: 'config file name in $Home/.kube'
|
|
||||||
required: false
|
|
||||||
default: 'config'
|
|
||||||
force:
|
force:
|
||||||
description: 'force override'
|
description: 'force override'
|
||||||
required: false
|
required: false
|
||||||
|
|
|
||||||
|
|
@ -26587,27 +26587,20 @@ 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 { writeFileSync, existsSync, mkdirSync } = __nccwpck_require__(7147);
|
const { mkdir, writeFileSync, existsSync } = __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")
|
||||||
mkdirSync(parentDir,{recursive:true})
|
mkdir(parentDir,{recursive:true})
|
||||||
const configFileName = core.getInput("configFileName")
|
const configFile = path.join(parentDir,"config")
|
||||||
const configFile = path.join(parentDir,configFileName)
|
|
||||||
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
||||||
throw {
|
throw {
|
||||||
message:`.kube/${configFileName} exists`
|
message:".kube/config 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.5",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "action-kubernetes-login",
|
"name": "action-kubernetes-login",
|
||||||
"version": "0.0.5",
|
"version": "0.0.0",
|
||||||
"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.5",
|
"version": "0.0.0",
|
||||||
"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,25 +1,18 @@
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const { writeFileSync, existsSync, mkdirSync } = require('fs');
|
const { mkdir, writeFileSync, existsSync } = 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")
|
||||||
mkdirSync(parentDir,{recursive:true})
|
mkdir(parentDir,{recursive:true})
|
||||||
const configFileName = core.getInput("configFileName")
|
const configFile = path.join(parentDir,"config")
|
||||||
const configFile = path.join(parentDir,configFileName)
|
|
||||||
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
if(existsSync(configFile) && !core.getBooleanInput("force")){
|
||||||
throw {
|
throw {
|
||||||
message:`.kube/${configFileName} exists`
|
message:".kube/config 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