-
-
Save FaisalAl-Tameemi/d34bbf8f38083bd5fd59f742207ea064 to your computer and use it in GitHub Desktop.
CircleCi - only build features that has changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -e | |
# latest commit | |
LATEST_COMMIT=$(git rev-parse HEAD) | |
# latest commit where path/to/folder1 was changed | |
FOLDER1_COMMIT=$(git log -1 --format=format:%H --full-diff path/to/folder1) | |
# latest commit where path/to/folder2 was changed | |
FOLDER2_COMMIT=$(git log -1 --format=format:%H --full-diff path/to/folder2) | |
if [ $FOLDER1_COMMIT = $LATEST_COMMIT ]; | |
then | |
echo "files in folder1 has changed" | |
.circleci/do_something.sh | |
elif [ $FOLDER2_COMMIT = $LATEST_COMMIT ]; | |
then | |
echo "files in folder2 has changed" | |
.circleci/do_something_else.sh | |
else | |
echo "no folders of relevance has changed" | |
exit 0; | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: circleci/... | |
steps: | |
- checkout | |
- run: | |
command: | | |
.circleci/build_directory.sh | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The idea is that the actual CircleCI job only runs a shell script. The shell script then checks which folders have been effected with the commit using regular
git
commands.The git commands then figure out which folder (service/lib) has been changed and does the relevant build steps.