feat(ci): on push to dev, update git sub modules on specified

!38
This commit is contained in:
2023-05-31 14:41:43 +09:30
parent 73ea66e60d
commit 7018440dcb
3 changed files with 79 additions and 0 deletions

View File

@ -120,3 +120,33 @@ gilab-ci.yml Lint (python 3.11):
extends:
- .yaml_lint_defaults
image: python:3.11-slim
Docker_Mail.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-mail
git_configuration.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible/git_configuration
# Ansible-roles.Submodule.Deploy:
# extends: .submodule_update_trigger
# variables:
# SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/ansible-roles
Ops.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/ops
Website.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/infrastructure/website

View File

@ -45,3 +45,19 @@ include:
# - ".nfc_automation.yaml"
- when: never
.submodule_update_trigger:
stage: publish
trigger:
project: $SUBMODULE_UPDATE_TRIGGER_PROJECT
branch: development
forward:
yaml_variables: false
variables:
PIPELINE_RUN_TRIGGER: 'true'
rules:
- if: $CI_COMMIT_TAG
when: never
- if: '$CI_COMMIT_BRANCH == "development" && $CI_PIPELINE_SOURCE == "push"'
when: on_success
- when: never

View File

@ -9,6 +9,8 @@ about: https://gitlab.com/nofusscomputing/projects/gitlab-ci
This job enables you to run an Ansible playbook within the Gitlab CI/CD environment.
There is also an additional job defined that enables you to specify a project to run an automated update of it's git submodules. This is useful if the project you create the job in, is used as a git submodule in another project. On pushing to the development branch, this job triggers the `Git.Submodules.Update.Chores` job that updates the specified projects git submodules.
This job provides the following badge:
- None
@ -18,6 +20,16 @@ This job provides the following badge:
- **Mandatory** file `.nfc_automation.yaml` see [Documentation](../git_configuration/submodule/) for file details.
- **Mandatory** In addition to the previous dependency, this requirement is for the project specified in the trigger job. The following must be added to the `.gitlab-ci.yml` file in that project.
``` yaml
include:
- project: nofusscomputing/projects/gitlab-ci
ref: master
file:
- .gitlab-ci_common.yaml
- automation/template/automagic.gitlab-ci.yaml
## your .gitlab-ci.yml changes
@ -44,6 +56,26 @@ Ansible Job:
```
To run the trigger job to update another projects git submodules.
``` yaml
stages:
- publish
include:
- project: nofusscomputing/projects/gitlab-ci
ref: master
file:
- automation/.gitlab-ci-ansible.yaml
Docker_Mail.Submodule.Deploy:
extends: .submodule_update_trigger
variables:
SUBMODULE_UPDATE_TRIGGER_PROJECT: nofusscomputing/projects/docker-mail
```
!!! Tip
You can optionally override the stage by specifying the job you define
@ -56,6 +88,7 @@ Ansible Job:
| ansible_tags | ***Optional** Tags to limit task scope* |
| PIPELINE_RUN_TRIGGER | ***Optional** if the job can be triggered by pipeline.* |
| PIPELINE_RUN_SCHEDULE | ***Optional** if the job can be triggered by schedule.* |
| SUBMODULE_UPDATE_TRIGGER_PROJECT | ***Mandatory** and only used for the Submodule.Deploy job. and is the project to trigger the `git.submodule.update.chores` job.* |
!!! Tip
In addition to the variables above, you can also specify any additional Environment variables for use by Ansible. Refer to the [Ansible configuration documentation](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#common-options) for further details