You can setup rules
for jobs which would run the job only if some files are changed.
This way you can have a separate unittest and deploy job for each API you maintain in your repository which is executed only if specific API is changed.
You can setup a hidden job with common parameters and use it to extend actual jobs.
stages:
- unittest
- deploy
.unittest_template:
stage: unittest
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != "master"
changes:
- $APIDIR/*
- when: never
other_common_parameters
.deploy_template:
stage: deploy
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"
changes:
- $APIDIR/*
- when: never
other_common_parameters
My-Api-1:unit test:
extends: .unittest_template
variables:
APIDIR: 'My-Api-1'
My-Api-1:deploy:
extends: .deploy_template
variables:
APIDIR: 'My-Api-1'