Skip to content

Instantly share code, notes, and snippets.

@pcmehrdad
Forked from ssbostan/pipeline.sh
Created January 12, 2021 20:00
Show Gist options
  • Save pcmehrdad/eb4038fc1822f0037cb4f9310c782225 to your computer and use it in GitHub Desktop.
Save pcmehrdad/eb4038fc1822f0037cb4f9310c782225 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