Tools to easily deploy your application.
- Clone the project:
git clone [email protected]:LowieHuyghe/deploy-tools.git
- Move into the new directory:
cd deploy-tools
- Setup virtualenv and activate it
- Install the requirements:
pip install -r requirements.txt
You can set the tool up in Google Cloud Shell, or locally. Whichever you prefer.
Features:
- Automatic composer install
- Automatic npm install
- Caching to speed up deploy
- Automatic increase of app.yaml-version
- Automatic release-commit and -tagging
- Custom commands
- Create a separate directory for the deploy-files of your project.
- Make a deploy.yaml file like so:
deploy:
name: Deploy tools
repository: [email protected]:LowieHuyghe/deploy-tools.git
branch: master
caching: true
persistent:
relative/path/to/file/starting/from/deploy.yaml: relative/target/path
/absolute/path/to/.env: relative/target/.env
before_all:
- apt-get install php5-curl
before_deploy:
- gulp --cwd {{directory}} build:prod
- echo 'Other variables are {{environment}}, {{branch}}'
after_success:
- echo 'The deploy was a great success'
after_failed:
- echo 'The deploy has failed'
notifications:
slack:
webhook: https://hooks.slack.com/services/ABCDEFGHIJKLMNOPQRSTUVWXYZ
channel: deploy-feed
username: Deploy Bot
icon: :robot_face:
- deploy: General deploy config
- name: Name of the project
- repository: The repository to deploy
- branch: The branch to deploy (default: master)
- caching: Enable caching when cloning repo, doing npm install, doing composer install,... (default: true)
- persistent: Persistent files (ideal for .env-files and similar) (default: {})
- before_all: Custom commands to run first hand (default: []). You can use variables that will be replaced at runtime:
{{environment}}
: The current environment{{directory}}
: The working directory{{branch}}
: The deploy branch
- before_deploy: Custom commands to run before deploying (default: []). Same variables as before_all can be used.
- after_success: Custom commands to run after successful deploy (default: []). Same variables as before_all can be used.
- after_failed: Custom commands to run after failed deploy (default: []). Same variables as before_all can be used.
- notifications
- slack: Setup notification-callback for Slack while deploying
- webhook: Webhook URL for Slack
- channel: Channel to post notifications in
- username: Username for Webhook
- icon: Icon for Webhook
- slack: Setup notification-callback for Slack while deploying
- Start deploying:
python deploy.py gae
Note: Make sure your virtualenv is active when running the script.
This explains the timeline of the deploy sequence and which actions are done.
- Load
deploy.yaml
and check required properties. - Confirm that the user wants to deploy.
- Make a temporary working dir.
- Run the before all commands described in
deploy.yaml
. - Clone the git repo and checkout the given branch. When caching is enabled, the repo will be cached and reused on next deploy (when reusing, the repo is fetched and reset to the remote).
- Copy the persistent files described in deploy.yaml to the working directory.
- When composer.json is available, run
composer install (--no-dev)
. - When package.json is available, run
npm install (--production)
. - Update
app.yaml
:
- Production:
- Increase patch-version
- Commit as new release
- Tag as new release
- Else:
- Change
application
toORIGINALAPPLICATION_{{environment}}
- Increase patch-version
- Add
APP_ENV: {{environment}}
toenv_variables
- Require
login: admin
for each handler (more info) - Also apply
APP_ENV: {{environment}}
to any.env*
-files
- Change
- Run the before deploy commands described in
deploy.yaml
. - Deploy the application to Google App Engine.
- If deploy failed, run the after failed commands.
- If production, push the new commit and tag to the repository.
- If deploy succeeded, run the after success commands.
- Done.