Skip to content

Instantly share code, notes, and snippets.

@himanoa
Last active July 7, 2020 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save himanoa/f1cb8b30f4ff64c97764c66daeabd2e8 to your computer and use it in GitHub Desktop.
Save himanoa/f1cb8b30f4ff64c97764c66daeabd2e8 to your computer and use it in GitHub Desktop.
circleciのcontextのセットアップをシュッってやる、zshスクリプトを生成する雑コマンド
/*
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