https://pulumi.com logo
#general
Title
# general
a

average-dream-51210

06/02/2019, 1:30 AM
Hm, if I used a git branch per pulumi stack for dev/stage/prod would it be wise to create a githook to execute a stack switch with pulumi upon git checkout to another branch?
b

big-piano-35669

06/02/2019, 1:49 AM
Effectively, that's exactly right. The specific details do depend a lot on what CI/CD system you're using, although you say "githook" so I wonder, are you doing this without a CI/CD server and wanting to execute the commands as local git hooks? For CI, there are some good pointers here: https://pulumi.io/reference/cd-travis/. If you end up down the road breaking your project into many stacks, you'll need something like https://blog.pulumi.com/continuous-delivery-with-gitlab-and-pulumi-on-amazon-eks, however if you're sticking to "monolithic" stacks for dev/stage/prod (by far, the easiest option), then the CI/CD docs above should suffice.
a

average-dream-51210

06/02/2019, 2:11 AM
Awesome thank you! We're doing it manually in the terminal first to get the dev team used to all these new tools, then will automate with CI/CD. Yup we're monolithic for the most part out the gate.
b

big-piano-35669

06/02/2019, 2:12 AM
Sounds great -- don't hesitate to reach out if you have any other questions.
a

average-dream-51210

06/02/2019, 2:33 AM
kk got it 🙂 appreciate it
b

brave-salesmen-42327

06/03/2019, 5:38 PM
Because it's java script, your flexibility is high! Consider a build script, using any of multiple task runners, or your own task runner where you:
Copy code
const BRANCH = execSync(`git rev-parse --abbrev-ref HEAD`).toString('utf8').trim()
const STACK = `exampleOrg/${BRANCH}`

var tasks = {
  update: () => {
    sh(`pulumi update -y --skip-preview --stack ${STACK}`)
    tasks.test()
  }
  ,test: () => {
    sh(`npm ${options.debug? 'run test-debug':'test'}`)
  }
}
You can even get the branch from inside your index.ts script and change up your stack inputs from the same stack, based on what branch you are on.
a

average-dream-51210

06/03/2019, 8:26 PM
awesome thanks for the tip!