Last active
July 7, 2020 05:56
-
-
Save himanoa/f1cb8b30f4ff64c97764c66daeabd2e8 to your computer and use it in GitHub Desktop.
circleciのcontextのセットアップをシュッってやる、zshスクリプトを生成する雑コマンド
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Requirements: [circleci](https://github.com/CircleCI-Public/circleci-cli) | |
*/ | |
const orgName = "YOUR ORGNAME"; | |
const contexts = [ | |
{ | |
name: "context-name", | |
// 環境変数名をkey 環境変数に代入したい値をvalueに入れる | |
}, | |
]; | |
function buildCircleCICommand(envs) { | |
return envs.map(env => { | |
const { name, ...e } = env; | |
return [ | |
`circleci context create github ${orgName} ${name}`, | |
...Object.keys(e).map(key => { | |
if(e[key] === "") { | |
return undefined; | |
} | |
return `echo "${e[key]}" | circleci context store-secret github ${orgName} ${name} ${key}` | |
}).filter(v => v !== undefined) | |
] | |
}) | |
} | |
console.log(["!/usr/bin/env zsh", buildCircleCICommand(contexts).flat()].join("\n")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment