The contained GitLab configuration file (.gitlab-ci.yml) is a simple, yet powerful way to leverage Harbormaster and GitLab to automate the generation of an MVP-quality project built on, tested, contained and deployed through your GitLab CI/CD pipeline.
This repository also contains sample Harbormaster project generation YAML files. These instructions will reference the Django project file (django-project-as-code.yaml)
To take a quick test drive, follow the instructions in the Quick Start section or skip to the Step-By-Step section to generate an application using more customized inputs.
Use this section to make the least amount of changes to see Harbormaster project generation in action.
1.) Git Clone this project in one of two ways:
SSH - git@github.com:Harbormaster-AI/gitlab.git
HTTPS - https://github.com/Harbormaster-AI/gitlab.git
2.) Edit the git section of /samples/yamls/project.as.code/django-project-as-code.yml
to set your GitLab username and password. Leave the password blank if you assigned a Person Token and applied it to your account at platform.harbormaster.ai
3.) Create a GitLab repository by the name of django_repo.
4.) Create a GitLab pipeline that is connected to the GitLab django_repo
5.) Commit your changes to this project to the django_repo and observe the GitLab pipeline status.
6.) Once the job in the pipeline is complete, check its status. A project will have been generated using a default model and a Django tech stack.
The project will eventually be built and tested with results as below:
Clone this project in one of two ways:
SSH - git@github.com:Harbormaster-AI/gitlab.git
HTTPS - https://github.com/Harbormaster-AI/gitlab.git
It is important you register @ harbormaster.ai in order to obtain an API token.
Once you have this token, assign it to an environment variable named
HARBORMASTER__API__TOKEN
Learn more about assign environment variables here
This YAML file contains the directives required to generate a project including:
- model identifier (by name, id or file_path)
- tech stack (by name or id),
- application options (name, description, author, etc..)
- GitLab repo settings,
- Docker settings
- and more....
See an example here
PROJECT_YAML_FILE: "samples/yamls/project.as.code/django-project-as-code.yml"
Modify the git: section of the a Project-As-Code YAML file (e.g. django-project-as-code.yml) to assign your GitLab credentials
Note: If using one of the AWS Lambda stacks, you will have to assign the access key and secret key as project level environment variables. See https://gitlab.com/help/ci/variables/README#variables for more details. Be sure to name the accesskey USER_AWS_ACCESSKEY and name the secretkey USER_AWS_SECRETKEY. Equally important, make sure you have the correct policies assigned for the related user (AWSCodeDeployRoleForLambda, AWSLambdaExecute, AWSLambdaRole, etc..)
Create a GitLab project repository (Repo A) for the generated project files. This repository name must be the name you assigned in the GIT section of the PROJECT_YAML_FILE (e.g. django-project-as-code.yml).
Create another GitLab project repository (Repo B) and commit this project to it. Any name will do. You are committing the modified .gitlab-ci.yml file along with the PROJECT_YAML_FILE discussed above. Only the .gitlab-ci.yml must be in the root.
Upon committing this project to Repo B, the .gitlab-ci.yml should begin running within a bound GitLab pipeline. The project is now being generated by Harbormaster.
Upon completion of Step 5, Harbormaster will commit all generated project files to Repo A. This should cause a GitLab pipeline to run the generated .gitlab-ci.yml file. The generated project is now being built and tested.
Using the power of GitLab and Harbormaster you just generated, built, tested, and (optionally) contained an entire application complete with core capabilities, build file, CI/CD config, and much more....
Best of luck in completing the application!