{"id":21493372,"url":"https://github.com/microdevops-com/gitlab-ci-functions","last_synced_at":"2025-07-15T19:30:48.429Z","repository":{"id":34469917,"uuid":"162816339","full_name":"microdevops-com/gitlab-ci-functions","owner":"microdevops-com","description":"Reusable CI script functions for Kubernetes, RabbitMQ, PostgreSQL etc","archived":false,"fork":false,"pushed_at":"2025-06-16T06:08:05.000Z","size":187,"stargazers_count":26,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-16T07:23:06.658Z","etag":null,"topics":["docker","git","gitlab-ci","k8s","kubernetes","postgresql","rabbitmq","rancher"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microdevops-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-12-22T14:06:47.000Z","updated_at":"2025-06-16T06:02:35.000Z","dependencies_parsed_at":"2023-12-24T12:28:28.296Z","dependency_job_id":"4a1d88ca-5dbb-420d-b0ee-fab30fcd1b48","html_url":"https://github.com/microdevops-com/gitlab-ci-functions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/microdevops-com/gitlab-ci-functions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microdevops-com%2Fgitlab-ci-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microdevops-com%2Fgitlab-ci-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microdevops-com%2Fgitlab-ci-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microdevops-com%2Fgitlab-ci-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microdevops-com","download_url":"https://codeload.github.com/microdevops-com/gitlab-ci-functions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microdevops-com%2Fgitlab-ci-functions/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265454947,"owners_count":23768457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","git","gitlab-ci","k8s","kubernetes","postgresql","rabbitmq","rancher"],"created_at":"2024-11-23T15:42:12.636Z","updated_at":"2025-07-15T19:30:48.150Z","avatar_url":"https://github.com/microdevops-com.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\nFunctions to create dynamic envs per $CI_COMMIT_REF_SLUG.\n- Rancher project namespaces\n- RabbitMQ virtual hosts\n- Docker Registry parallel logins\n- PostgreSQL databases\n\nKubectl, rancher cli, helm calls are parallel job safe.\n\n# Usage\n## Add this repo as Git Submodule to a project\n\n```\ngit submodule add --name .gitlab-ci-functions -b master -- https://github.com/sysadmws/gitlab-ci-functions .gitlab-ci-functions\n```\n\nP.S. You can directly fetch code from https://raw.githubusercontent.com each time pipeline runs, it is a quick way to start, but not a smart way to use permanently.\n```\nbefore_script:\n  - rm -f kubernetes.sh \u0026\u0026 curl -L -s -o kubernetes.sh https://raw.githubusercontent.com/sysadmws/gitlab-ci-functions/master/kubernetes.sh \u0026\u0026 . ./kubernetes.sh\n  - ...\n\n...\n\nafter_script:\n  - . ./kubernetes.sh\n  - rancher_logout\n  - ...\n```\n## Pipeline\nAdd the following to `.gitlab-ci.yml` depending on needs:\n```\nvariables:\n  GIT_SUBMODULE_STRATEGY: normal\n\nbefore_script:\n  - . .gitlab-ci-functions/kubernetes.sh\n  - . .gitlab-ci-functions/docker.sh\n  - . .gitlab-ci-functions/rabbitmq.sh\n  - . .gitlab-ci-functions/postgresql.sh\n  # this vars are available to script but not available to yml\n  - KUBE_NAMESPACE=$(kubernetes_namespace_sanitize $RANCHER_PROJECT-$CI_COMMIT_REF_SLUG)\n  - RABBITMQ_VHOST=$(rabbitmq_vhost_sanitize $RABBITMQ_VHOST_PREFIX-$CI_COMMIT_REF_SLUG)\n  - registry_login\n  - rancher_login\n  - helm_cluster_login\n\nafter_script:\n  - . .gitlab-ci-functions/kubernetes.sh\n  - rancher_logout\n  - helm_cluster_logout\n\n...\n\nprepare_rabbitmq_vhost:\n  stage: prerequisites\n  script:\n    - rabbitmq_create_vhost $RABBITMQ_VHOST\n    - rabbitmq_add_permission $RABBITMQ_VHOST $RABBITMQ_USER\n\nprepare_postgresql_db:\n  stage: prerequisites\n  script:\n    - postgresql_create_db $POSTGRESQL_DB_PREFIX-$CI_COMMIT_REF_SLUG\n  \n\nprepare_rancher_namespace:\n  stage: prerequisites\n  script:\n    - rancher_namespace\n    - namespace_secret_project_registry\n    - namespace_secret_rabbitmq rabbitmq\n    - helm_init_namespace\n\nmy-app:\n  stage: app_deploy\n  script:\n    - helm_deploy my-app $CI_COMMIT_REF_SLUG\n    #- helm_deploy my-app $CI_COMMIT_REF_SLUG \"--set env=dev\"\n```\n## Envs\nRequired envs for CI:\n```\nRANCHER_PROJECT=Project\n\nRABBITMQ_HOST=rabbitmq.example.com\nRABBITMQ_PORT=5672\nRABBITMQ_MANAGEMENT_PORT=15672\nRABBITMQ_USER=project-user\nRABBITMQ_PASS=PASS1\nRABBITMQ_MANAGEMENT_USER=project-admin\nRABBITMQ_MANAGEMENT_PASS=PASS2\nRABBITMQ_VHOST_PREFIX=project\nPOSTGRESQL_HOST=postgresql.example.com\nPOSTGRESQL_PORT=5432\nPOSTGRESQL_USER=project-user\nPOSTGRESQL_PASS=PASS2\nPOSTGRESQL_DB_PREFIX=project\n\nKUBE_SERVER=https://rancher.example.com/k8s/clusters/local\nKUBE_TOKEN=kubeconfig-u-xxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nADMIN_EMAIL=admin@example.com\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrodevops-com%2Fgitlab-ci-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrodevops-com%2Fgitlab-ci-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrodevops-com%2Fgitlab-ci-functions/lists"}