How to invoke pre/post deployment scripts during Heroku pipeline promotions - heroku

I have a rails app that runs database migrations in a rake task after tests have succeeded and immediately before deploying code to Heroku.
I am using CodeShip to run the tests, run the migrations, and then finally deploy to heroku.
However, I am running into a problem with Heroku's new Pipelines feature.
Upon promoting a version of my app from one environment to another, only the the application slug is copied over to the new environment. No branches are merged or updated in git, and no codeship builds trigger.
Even the heroku build history shows only a promotion entry with no build log associated. Which makes sense since it is just copying the slug over, not building a new slug.
So my problem is that when I promote my app to a new environment, I am not able to find any way of hooking a custom script into that event to perform database migrations.
Main Question
Is there support for this that I am just having trouble finding? If not, is a feature in the works that would support this?
Feature Suggestion
Ideally I would like the promotion feature to work by merging the underlying git branches, that way codeship could still kick off, run all tests and migrations again in the new environment, and then finally trigger the build in the next environment. This would require each environment in the pipeline to be tied to a specific branch, instead of just promoting by commit hash, but I don't think that would be problematic.
Essentially I would like the promote button to just do what we developers would often do when manually promoting a version of our app, merge to a git branch associated with that environment and let our CI server's git hooks kick it off from there.

Post-promotion script can be defined in Procfile with release process type.
release: npm run migrate

Related

How do I duplicate my Heroku app to add to a pipeline?

I'm beginning to understand how Heroku works, but haven't yet used a pipeline. I have an app I'm working on that is near its first production version. I'd like to begin using pipelines.
But I don't understand how to begin. What do I need to do to make a copy of the current app and have that copy be in the development stage and make another copy for the staging stage? Do I fork my git repository twice and add each one?
I'm trying to take this one step at a time. I don't need GitHub integration yet. This is a small project and will not have any pull requests for quite some time, if ever. I'm only interested in the ability to develop, stage and release in the three stages offered by Heroku.
While pipelines do use multiple apps, they should use the same git repository with different remotes. Heroku's help page helped me understand that the process is to link the repository to each app different remote names and then push to the remote that I'm currently working on.

Azure DevOps Release pipeline for create-react-app and GitFlow?

We have a creat-react-app application, which includes a couple of variables that are different (react) build time, depending on where the build will be deployed. For example, we need to specify build time which URL will be used, e.g. https://app-stage.company.com for a release-x.y.z build vs. https://app.company.com for a master build (please refer to this article about GitFlow). We've already created such a build pipeline as suggested here, which will build with the appropriate react config for any commit to branches master, release-x.y.z, dev, hotfix-x.y.z.
We would like to create a release pipeline now, that reflects the GitFlow process and makes use of the automated builds.
The release pipeline should deploy to a dev site for a dev build, to a stage site for a release-x.y.z build, etc. I know I can inspect the source branch from a build and filter/modify config/variables based on it. Fine, so I can create a release pipeline with a single stage, whose config is modified on the fly based on which source branch was built.
But I understand that release pipelines "should" have a series of stages, i.e. dev -> stage -> production, probably with approvals inbetween. I can't see how this could be achieved in this scenario.
Suggestions?
Our idea as of now is to just have that single modified-on-the-fly stage in the release pipe and handle the stages from git merges/pull requests, according to GitFlow.

Parse Cloud Code development and production version control

I have a Parse application that will soon be used in production, and I need to be able to continue developing things locally without breaking things for live users when I make changes to cloud code.
I have cloned the app, and can now deploy to either the production or staging app using the parse deploy staging and parse deploy production commands, however these commands only work if I am on the master branch.
What I would like to have are two branches in git, one that can be pushed to my staging app, and the other that can be pushed to the production app.
At the moment all I can think of doing is to just tag commits in master as being pushed to production, then continue ontop of that for development, but that is going to be a nightmare if I need to patch the released app when I have all my development changes on master.
Pushing directly to the heroku git repos doesn't seem to work either, parse deploy must be doing something extra (plus it tries to build the app so I can see when things go wrong).
Another issue is that when other developers start working on this as well, we won't be able to all deploy to the development server, and as far as I know there isn't an easy way to run parse cloud code locally on windows.
What is the best way to manage all this?
You have to setup parse-server (use parse-server-example), parse-dashboard and mongoDB on a local or remote development server. You and your team can now develop everything locally, test and then deploy to production.

Netezza CI/CD tool

Is there any CI/CD tool for Netezza that can manage versions and can be used for migrating code across environments? We have used flywaydb for other databases and are happy with it, but that does not support Netezza. I have already googled and did not find a single tool, so any responses are good for me to begin analyzing further
To my knowledge, there's nothing specifically geared for Netezza. That said, with a bit of understanding of your target environment, it's certainly possible.
We use git and GitHub Enterprise (GHE). The reason for GHE is not particular to this solution, but rather because I work at a hospital. Here's what we do.
Setup
Build a repository at /home/nz on your production server. Depending on how you work nzlogs, nzbads, and other temporary files, you may need to fiddle quite a bit with the .gitignore file. We have dedicated log directories where temporary files should reside.
Push that repo into GHE.
If you have a development server, clone the repo in the /home/nz directory on that server. Clearly you'll lose all development work up until that point and will want to make sure that things like .bashrc are not versioned. Alternatively, you could set up a different branch and repo and try merging the prod and dev versions. We did this, but I'd recommend just wiping your development box with production code one slow day.
Assign your production box a dedicated branch in git. For this discussion, I'll call them prod and dev. Do the same for development, if you have it. This is mainly a mental thing, not a tech thing, but it's crucial, like setting up a remote for Heroku or Azure.
Find or develop a tiny web server that can listen for GitHub webhooks. I built a Sinatra server with a simple configuration file. Anything will do. Deploy the web server to each of the environments and tune them to perform the following activities on an update to the prod or dev branches, respective to the server.
git reset --hard
git clean -f
git pull
Set up webhooks in your GHE repository to send the push event to the web servers.
Of course, you can always have the web server do other things on a branch update if you want to get fancy (maybe update cron from a versioned file or update schemas from all new files).
Process
Fairly simply, follow the GitHub Flow workflow. You can pretty much follow whatever process you want with the understanding that your prod and dev branches should be protected and only removed or futzed with as an admin task. Create a feature branch, test it by pushing to dev, and then make a pull request for the prod branch.
Why GHE? Mainly because it keeps an open area where our code is available. You could absolutely do this by pushing directly to Netezza's git repo, but your workflow will suffer--it just isn't as clean as having all code in one clear place with discussion around pull requests.

How do you deploy build artifacts to Heroku from Codeship?

In starting a new project, I put together the skeleton for a Node app that has tests and generates some build artifacts, like asset compilation and compression. I have the tests running in Codeship so successful builds initiate a deploy to Heroku. They've made it all super easy, except I can't find any way to deploy built files, just a copy of what's in the repo.
Has anyone done this successfully? I feel like writing a custom deploy script to rebuild the assets after the tests and manually deploy them would be working against the existing toolset, and I know can't possibly be the first person to want to do this...
Turns out that Codeship doesn't keep anything, in fact, different servers do the deployment than the testing. It seems that the best-practice here is to recreate the assets on the Heroku side with a custom buildpack, which, directly after the git pull, does the dependency installation and compiles the app slug.

Resources