CI/CD
LogCraft CLI has been designed to easily integrate into a CI/CD workflow.
Docker Image
You can access a pre-built Docker image that includes LogCraft CLI via the GitHub/Docker registry:
docker pull ghcr.io/logcraftio/logcraft-cli:latest
Packages
Docker images are available at: https://github.com/LogCraftIO/logcraft-cli/pkgs/container/logcraft-cli
Gitlab CI
Add the following snippet in the file .gitlab-ci.yml
. This example uses environment variables that are defined in Settings > CI/CD > Variables, this needs to be adjusted to fit your environment. Also note that lgc.yaml
can use environment variables (see demonstration repository)
include:
- 'https://gitlab.com/logcraft/ci-templates/-/raw/main/LogCraft.gitlab-ci.yml'
variables:
# Uses the branch name for the environment ID.
LGC_ENV_ID: $CI_COMMIT_REF_NAME
.env_rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# If merge request event, use the target branch name.
variables:
LGC_ENV_ID: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- if: $CI_COMMIT_REF_PROTECTED == "true"
variables:
LGC_ENV_ID: $CI_COMMIT_REF_NAME
stages:
- validate
- diff
- deploy
- destroy
diff:
extends: .lgc:diff
rules:
- !reference [ .env_rules ]
Regarding the variables
statement, there also exists the LGC_SERVICE_ID
environment variable that can be set. In that case, the commands run will be:
lgc [action] LGC_ENV_ID -s LGC_SERVICE_ID --auto-approve
Snippets
You may find our public templates to ease the integration of LogCraft CLI into a GitLab-CI at https://gitlab.com/logcraft/ci-templates
Sample Repository
Please refer to this sample repository that has a working CI/CD pipeline https://gitlab.com/logcraft/example-logcraft-project
Other CI/CD
We are looking for contributors willing to share configuration snippets 🙏