Flow State Flow State

Version control

End to end process

This article describes the end-to-end workflow, from pulling down code and creating a new branch to getting it reviewed and merged and then, finally, deploying it to production.

  • Start by pulling down the latest changes

    Pull from the `main` branch

    git checkout main && git pull origin main
  • Branch off to isolate the work in a temporary working branch

    Create a new branch following the naming convention

    To create a new branch and switch to it at the same time, you can run the git checkout command with the -b switch:

    git checkout -b feature/search-page

    Related resources

  • Work on the created branch

    Commit code often when it makes sense

    While working on the branch commit frequently and keep commits narrow and focused. A piece of work can contain many commits.

    git commit -m "feat: add search page layout"
  • Push to the remote repository

    Push code frequently - it’s a good idea to push when you finish a piece of work.

    git push --set-upstream origin feature/search-page

    Once the code is published:

    git push
  • Deploy the code for review

    Deploy

    After finishing work on a temporary branch, you can test it in Matrix, by deploying it and building /dist folder on the separate branch.


    To deploy head the the Pipeline interface in GitLab and click “New pipeline”.

    1. Select the branch you want to deploy (the same branch you pushed to)
    2. Add the variable DEPLOY with the value TRUE
    3. Add the variable BRANCH_NAME with the value of the deploy branch you wish to create or update
    Git Workflow Pipeline - deploy temporary branch

    After this pipeline runs successfully, you will see the new branch created. It will be prefixed with deploy/ and the name of the branch you specified. This branch only contains the /dist folder and is used to deploy the to Matrix using the Git Bridge asset.

  • Test feature in the Matrix environment

    Deploy

    Find an available feature Git Bridge, one that is not in use. Otherwise create a new one. Connect it to the deploy/ branch that was created in the previous step.

    Git Bridge Settings

    Now your static assets are available in Matrix. Depending on your implementation, you may need to do some additional work to get the feature working in Matrix. You can use conditional logic to load the working code instead of the production code.

    Related resources

  • Submit for review

    Quality

    It's now time to get the code and feature reviewed

    Submit your working code for review now, both internally and externally.

    Create a merge request in GitLab and move the Jira ticket into review.

    Communicate with the client that the work is ready for review and provide them with the link to test the work.

  • Respond to feedback

    Quality

    Make the necessary changes

    If there is feedback from the client or internal peer review, make the necessary changes and push them to the branch. Redeploy the code using the same branch name and Git Bridge. Keep doing this until the code passes review.

  • Merge the working branch

    Code has passed the review stage

    Head the the merge request in GitLab and click “Merge”. Select “Delete source branch”.

    Merge to main
  • Deploy to production

    Deploy

    Trigger a production deploy and tag

    After a successful merge of the temporary branch to the main, it’s time to deploy to production.

    To deploy head the the Pipeline interface in GitLab and click “New pipeline”.

    1. Deploy from the main branch
    2. Add the variable DEPLOY with the value TRUE
    3. Add the variable BRANCH_NAME with the value of production
    Deploy production

    This will update the deploy/production branch, that contains the /dist directory only.

    More importantly, a Git tag is created using the naming convention, production-<date>-<time>.

    Created Git Tags can be found in the Repository tab under Tags.

    Tag interface

    The newly created tag will be called something like production-20230710-064221. Copy the tag name, ready for the next step.

  • Update production Git Bridge

    Deploy

    Finally, we need to update the Git Bridge associated with the production environment. Simply paste the tag name into the Git Bridge settings and click “Update Git Bridge”.

    Git Bridge Settings

    Now your production environment is updated with the latest code. You may experience caching issues, so it’s a good idea to clear the cache in Matrix.

  • Remove deploy branch to keep repository clean

    It’s recommended to remove the deploy branch after successfully deploying a feature to production. Select the Branches tab under the Repository and locate the branch you have been working on, e.g., deploy/working-branch. Then, click on the delete option to remove the branch.

    Git Bridge Settings
  • Production code is live

    Awesome job!