Skip to content

Instantly share code, notes, and snippets.

@ssbostan
Created April 22, 2020 07:50
Show Gist options
  • Save ssbostan/31a17704d69dc90245595ca0fb8a3a29 to your computer and use it in GitHub Desktop.
Save ssbostan/31a17704d69dc90245595ca0fb8a3a29 to your computer and use it in GitHub Desktop.
Write CI/CD Pipeline with Bash
#!/bin/bash
# Copyright (c) 2020, Saeid Bostandoust
# ssbostan@linuxmail.org
# https://b9t.ir
# All rights reserved.
PIPELINE_PROJECT_NAME="YOUR-PROJECT-NAME"
if [[ ! -d "./$PIPELINE_PROJECT_NAME" ]]; then
git clone YOUR-GIT-ADDRESS
fi
git -C ./$PIPELINE_PROJECT_NAME pull > /dev/null
touch .lastcommit
PIPELINE_LAST_COMMIT=$(cat .lastcommit)
PIPELINE_REAL_COMMIT=$(git -C ./$PIPELINE_PROJECT_NAME rev-parse --short HEAD 2> /dev/null || echo 0)
if [[ "$PIPELINE_LAST_COMMIT" != "$PIPELINE_REAL_COMMIT" ]]; then
echo $PIPELINE_REAL_COMMIT > .lastcommit
# Write your code here.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment