-
Notifications
You must be signed in to change notification settings - Fork 0
Branch Workflow
Here, we describe how we handle branches.
🚨🚨🚨 BE VERY CAREFUL WITH PROD BRANCHES. DO BACKUPS BEFORE CHANGING THEM. SEE Docker Deploy FOR MORE INFO.
- Merge
mainintodev - Make a PR to merge
devintomain - Make a PR to merge
mainintoprod - On the server's
prodbranch, rungdiff - Backup your current branch:
git checkout -b prod_legacy - Pull changes:
git pull origin prod - Build AIKON
Minimally, an AIKON project should have 3 branches:
* main
* dev
* prod
-
mainis a stable and functionnal branch -
devis the local work where you do your work -
prodis the branch of the in-production instance of your AIKON app.
We have 3 branches and a prod branch because in-production apps often need specific configs related to the server or the AIKON instance. For example:
- a production server may use a proxy that requires specific NGINX configs and Docker options
- depending on the app's language, there are different database migrations.
😰 When merging into prod, be very careful of:
-
front/app/docker: the Docker folder. Don't blindly overwrite its comments with what comes frommain. It often contains configs specific to the server and to that app instance. -
front/app/webapp/migrations: migrations change depending on the app's language.
You work in dev, merge with main once it's done, then merge main into prod and from that put in production.
-
Add the
gdiffcommand to yourbashrc. It allows you to compare local changes in a branch with remote changes, before pulling => be certain that you won't create a mess when pulling.cat << 'EOF' >> ~/.bashrc && source ~/.bashrc function git_branch() { if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then local branch_name=$(git branch 2>/dev/null | grep '^*' | colrm 1 2) if [ -n "$branch_name" ]; then echo "$branch_name" fi fi } alias gdiff='git fetch && git diff $(git_branch) origin/$(git_branch) -- ":(exclude)**/static/svelte/**"' EOF
-
On
dev, do your changes -
Merge
mainintodevonce your changes are done (if there are conflicts, they will be indevand not inmain)# start from dev and checkout into main git checkout main # pull git pull origin main # checkout into dev and merge. if necessary, fix issues. git checkout dev git merge main # push your changes git push origin dev
-
Create a pull request to merge
devintomain. There shouldn't be conflicts. -
Create a pull request to merge
mainintoprod. Be careful with conflicts. If there are conflicts, try to fix them locally and not on your prod server. - Backup your prod branch (see below)
-
Pull changes into
prodon your production server# start from your prod branch # make sure you don't do a messy pull gdiff # pull changes git pull origin prod
- Build your dockers to update your production app. See Docker deploy guide
Before pulling changes on your server, do a backup of the prod branch. Starting from your prod branch,
-
Delete the old backup branch
git branch -d prod_legacy
-
Create your backup branch
git switch -d prod_legacy
-
Commit it
git status # just to be sure you won't commit any errors git commit -am "[PROD] backup current state"
-
Push
git push -u origin prod_legacy
In practice, we have a lot more branches and AIKON is deployed on several servers. The workflow stays the same:
* *-dev # all of your dev branches
* main # your main stable branch
* *-prod # all of your production instance branches. There is typically 1 prod branch per instance +
1 backup branch
The workflow is the same:
- do your changes in your dev branch
- merge main into dev
- do a PR to merge your dev branch into
main - do a PR to merge
maininto your prod branch - backup your prod branch
- pull your prod branches and rebuilt your dockers.
For each *-prod branch, there is a *-prod_legacy backup branch. For example: aikon-prod => aikon-prod_legacy.