This issue aims to implement a Github CI/CD workflow generator for a Naas space. The workflow will be triggered when a new release/tag is created and managed by the semantic-release process.
Specifications
Implement the function naas.space.generate_ci(space_name, registry_name, dockerfile_path, docker_context, ci_type) in Python.
The CI/CD workflow should:
Checkout the code
Use a CI/CD variable/secret to authenticate on auth.naas.ai
Ask for temporary credentials on space.naas.ai/registry/registry_name/credentials to be able to login and push the built container
Docker login against the container registry
Get the url of the space by calling space.naas.ai/registry/registry_name
Build the container
Tag the container
Push the container
Update the space version by calling PUT space.naas.ai/space/space_name
GPT4 - Helpers
Creating a Github CI/CD workflow that will be triggered on new tags
To create a Github CI/CD workflow that is triggered on new tags, include the following in your workflow YAML file:
on:
push:
tags:
- '*'
This will ensure the workflow is only triggered on new tags, and not on every push to the repository.
Using Jinja2 with Python to template a file
Jinja2 is a popular templating engine for Python. To use Jinja2 to template a file, follow these steps:
Install Jinja2: pip install jinja2
Create a template file (e.g., template.j2) with placeholders for variable values, using the double curly brace syntax: {{ variable_name }}
In your Python script, import Jinja2 and load the template file:
with open('output_file.yaml', 'w') as output_file:
output_file.write(rendered_template)
Replace output_file.yaml with the desired output file name, and ensure the variable names in the template match the variables passed to the render() function.
Implement Github CI/CD Workflow for Naas space
This issue aims to implement a Github CI/CD workflow generator for a Naas space. The workflow will be triggered when a new release/tag is created and managed by the semantic-release process.
Specifications
naas.space.generate_ci(space_name, registry_name, dockerfile_path, docker_context, ci_type)
in Python.auth.naas.ai
space.naas.ai/registry/registry_name/credentials
to be able to login and push the built containerspace.naas.ai/registry/registry_name
space.naas.ai/space/space_name
GPT4 - Helpers
Creating a Github CI/CD workflow that will be triggered on new tags
To create a Github CI/CD workflow that is triggered on new tags, include the following in your workflow YAML file:
This will ensure the workflow is only triggered on new tags, and not on every push to the repository.
Using Jinja2 with Python to template a file
Jinja2 is a popular templating engine for Python. To use Jinja2 to template a file, follow these steps:
pip install jinja2
template.j2
) with placeholders for variable values, using the double curly brace syntax:{{ variable_name }}
Replace
output_file.yaml
with the desired output file name, and ensure the variable names in the template match the variables passed to therender()
function.Estimate: 1 Priority: Medium