gitlab | runner | ci/cd ansible | ci/cd www | ci/cd laravel | ci/cd react | sast
draft
vi .gitlab-ci.yml
stages:
- deploy
deploy daemons:
stage: deploy
variables:
ANSIBLE_DISPLAY_SKIPPED_HOSTS: true
ANSIBLE_FORCE_COLOR: true
script:
- ./.gitlab-ci/scripts/diff-tree
#- cd sshguard/
#- time ansible-playbook tasks-sshguard.yml --timeout 3 -i ../hosts -e "target=some-host" --check
#- time ansible-playbook tasks-sshguard.yml --timeout 3 -i ../hosts -e "target=some-host"
#- cd ../
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
tags:
- ansible
mkdir -p .gitlab-ci/scripts/
cd .gitlab-ci/scripts/
vi diff-tree
#!/bin/bash
set -e
# $CI_MERGE_REQUEST_TARGET_BRANCH_SHA
[[ -z $CI_COMMIT_SHA ]] && echo error: CI_COMMIT_SHA not defined && exit 1
# do not show repository root (.) nor hidden folders
# we only care about ansible role folders
folders=`git diff-tree --name-only --no-commit-id $CI_COMMIT_SHA | sed '/^\./d'`
[[ -z $folders ]] && echo nothing to do && exit 0
echo changed folders are $folders
echo
for folder in $folders; do
echo processing folder $folder
echo
done; unset folder