commit 4a48ddde792719d0d06e72d53bec18790bd81660
parent a8f2fd8f39b8eb4ccc1b579a7f792cdb8c48ee4b
Author: arjoonn <arjoonn@noreply.localhost>
Date: Wed, 8 Feb 2023 16:32:50 +0000
Easier installation (!36)
Branch auto created by JayporeCI
```jayporeci
╔ 🔴 : JayporeCI [sha 5f2f965c43]
┏━ build_and_test
┃
┃ 🟢 : JciEnv [820c9ebf] 0: 0
┃ 🟢 : Jci [2ebd4e92] 0:10 ❮-- ['JciEnv']
┃ 🟢 : black [e53e38f1] 0: 0 ❮-- ['JciEnv']
┃ 🟢 : pylint [41bcfd26] 0:11 ❮-- ['JciEnv']
┃ 🟢 : pytest [4e8ffd0a] 0: 3 65% ❮-- ['JciEnv']
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
┏━ Publish
┃
┃ 🟢 : DockerHubJci [df583d40] 0:24
┃ 🟢 : DockerHubJcienv [0d663f76] 0:25
┃ 🟢 : PublishDocs [40f2e2ca] 0:27
┃ 🔴 : PublishPypi [7289b831] 0: 5
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
```
Co-authored-by: arjoonn sharma <arjoonn@midpathsoftware.com>
Reviewed-on: https://gitea.midpathsoftware.com/midpath/jaypore_ci/pulls/36
Diffstat:
10 files changed, 66 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
@@ -10,5 +10,5 @@ Documentation is at : https://www.jayporeci.in
## Usage
-- Install : `curl https://get.jayporeci.in | bash`
+- Install : `curl https://www.jayporeci.in/setup.sh | bash`
- Trigger : `git push origin`
diff --git a/cicd/build_and_publish_docs.sh b/cicd/build_and_publish_docs.sh
@@ -8,6 +8,12 @@ build() {
echo "Building docs"
sphinx-apidoc -o docs/source/reference ./jaypore_ci
sphinx-build docs/source/ docs/build
+ cp cicd/pre-push.sh docs/build
+ cp setup.sh docs/build
+ cp -r secrets/bin docs/build
+ wget -O docs/build/sops https://github.com/mozilla/sops/releases/download/v3.7.3/sops-v3.7.3.linux
+ wget -O ./age.tar.gz https://github.com/FiloSottile/age/releases/download/v1.0.0/age-v1.0.0-linux-amd64.tar.gz
+ tar xf ./age.tar.gz && mv ./age/age docs/build/bin && mv ./age/age-keygen docs/build/bin && rm -rf ./age
(cd docs/build && zip -r ../../website.zip ./)
}
diff --git a/cicd/pre-push.sh b/cicd/pre-push.sh
@@ -32,6 +32,7 @@ hook() {
-d \
--name jayporeci__pipe__$SHA \
-e JAYPORE_CODE_DIR=$JAYPORE_CODE_DIR \
+ -e SHA=$SHA \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $REPO_ROOT:/jaypore_ci/repo:ro \
-v /tmp/jayporeci__src__$SHA:/jaypore_ci/run \
diff --git a/docs/source/index.rst b/docs/source/index.rst
@@ -37,7 +37,7 @@ You can easily install it using a bash script.
.. code-block:: console
- $ curl https://get.jayporeci.in | bash
+ $ curl https://www.jayporeci.in/setup.sh | bash
**Or** you can manually install it. These names are convention, you can call your folders/files anything.
diff --git a/secrets/bin/age b/secrets/bin/age
Binary files differ.
diff --git a/secrets/bin/age-keygen b/secrets/bin/age-keygen
Binary files differ.
diff --git a/secrets/bin/edit_env.sh b/secrets/bin/edit_env.sh
@@ -15,11 +15,12 @@ main (){
echo $KEY_FILE
echo $ENC_FILE
echo $PLAINTEXT_FILE
+ PATH="$BIN:$PATH"
if [[ -f "$SECRETS/$NAME.enc" ]]; then
- SOPS_AGE_KEY_FILE=$KEY_FILE $BIN/sops --decrypt --input-type dotenv --output-type dotenv $ENC_FILE > $PLAINTEXT_FILE
+ SOPS_AGE_KEY_FILE=$KEY_FILE sops --decrypt --input-type dotenv --output-type dotenv $ENC_FILE > $PLAINTEXT_FILE
fi
vim $PLAINTEXT_FILE
- $BIN/sops --input-type dotenv --output-type dotenv --encrypt --age $($BIN/age-keygen -y $KEY_FILE) $PLAINTEXT_FILE > $ENC_FILE
+ sops --input-type dotenv --output-type dotenv --encrypt --age $(age-keygen -y $KEY_FILE) $PLAINTEXT_FILE > $ENC_FILE
rm $PLAINTEXT_FILE
}
(main $1)
diff --git a/secrets/bin/set_env.sh b/secrets/bin/set_env.sh
@@ -3,4 +3,5 @@
BIN=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SECRETS=$(echo "$BIN/..")
NAME=$1
-export $(SOPS_AGE_KEY_FILE=$SECRETS/$NAME.key $BIN/sops --decrypt --input-type dotenv --output-type dotenv $SECRETS/$NAME.enc | xargs)
+PATH="$BIN:$PATH"
+export $(SOPS_AGE_KEY_FILE=$SECRETS/$NAME.key sops --decrypt --input-type dotenv --output-type dotenv $SECRETS/$NAME.enc | xargs)
diff --git a/secrets/bin/sops b/secrets/bin/sops
Binary files differ.
diff --git a/setup.sh b/setup.sh
@@ -6,22 +6,63 @@ main (){
REPO_ROOT=$(git rev-parse --show-toplevel)
LOCAL_HOOK=$(echo $REPO_ROOT/.git/hooks/pre-push)
IMAGE='arjoonn/jci:latest'
- echo "Working in repo: $REPO_ROOT"
- echo "Adding git hook at: $LOCAL_HOOK"
CICD_ROOT=cicd
- mkdir $REPO_ROOT/cicd || echo 'Moving on..'
- cat > $REPO_ROOT/cicd/cicd.py << EOF
+ echo "--------------------"
+ echo "Installing JayporeCI"
+ echo "--------------------"
+ echo "Installing in repo: $REPO_ROOT"
+ echo "Creating folder for cicd: $REPO_ROOT/$CICD_ROOT"
+ # ----------------<<<<<<<<<<<<<
+ read -r -p "Should we continue? [Y/n] " response
+ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
+ then
+ echo "Creating cicd.py and pre-push.sh"
+ else
+ exit 0
+ fi
+ mkdir $REPO_ROOT/$CICD_ROOT || echo 'Moving on..'
+ cat > $REPO_ROOT/$CICD_ROOT/cicd.py << EOF
from jaypore_ci import jci
with jci.Pipeline() as p:
p.job("Black", "black --check .")
EOF
-
- curl https://raw.githubusercontent.com/theSage21/jaypore_ci/main/cicd/pre-push.sh -o $REPO_ROOT/cicd/pre-push.sh
- # --------------
- echo "Creating git hook for pre-commit"
+ curl -s https://www.jayporeci.in/pre-push.sh -o $REPO_ROOT/cicd/pre-push.sh
chmod u+x $REPO_ROOT/cicd/pre-push.sh
-
+ # ----------------<<<<<<<<<<<<<
+ read -r -p "Do you want to create 'secrets' folder for environment variables? [Y/n] " response
+ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
+ then
+ mkdir -p secrets/bin
+ PATH="$REPO_ROOT/secrets/bin:$PATH"
+ read -r -p "Do you want to download age/sops binaries? [Y/n] " response
+ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
+ then
+ echo "Downloading age/ binaries"
+ wget --quiet -O $HOME/.local/bin/age http://www.jayporeci.in/bin/age &
+ wget --quiet -O $HOME/.local/bin/age-keygen http://www.jayporeci.in/bin/age-keygen &
+ wget --quiet -O $HOME/.local/bin/sops http://www.jayporeci.in/bin/sops &
+ wait
+ fi
+ echo "Downloading edit/set env scripts"
+ wget --quiet -O secrets/bin/edit_env.sh http://www.jayporeci.in/bin/edit_env.sh &
+ wget --quiet -O secrets/bin/set_env.sh http://www.jayporeci.in/bin/set_env.sh &
+ wait
+ echo "Created $REPO_ROOT/secrets/bin"
+ echo "Adding gitignore so that key and plaintext files are never committed"
+ echo "*.key" >> .gitignore
+ echo "*.plaintext" >> .gitignore
+ echo "Creating new age-key at: $REPO_ROOT/secrets/ci.key"
+ age-keygen > $REPO_ROOT/secrets/ci.key
+ echo "You can now use (bash secrets/bin/edit_env.sh ci) to edit environment variables."
+ read -r -p "Do you want to edit_env now? [Y/n] " response
+ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
+ then
+ (bash $REPO_ROOT/secrets/bin/edit_env.sh ci)
+ fi
+ fi
+ # ----------------<<<<<<<<<<<<<
+ echo "Creating git hook for pre-push"
if test -f "$LOCAL_HOOK"; then
if test -f "$LOCAL_HOOK.local"; then
echo "$LOCAL_HOOK has already been moved once."
@@ -37,12 +78,11 @@ EOF
exit 1
else
echo "$LOCAL_HOOK exists. Moving to separate file"
- mv $LOCAL_HOOK $REPO_ROOT/.git/hooks/pre-push.local
- echo "$REPO_ROOT/.git/hooks/pre-push.local" >> $REPO_ROOT/.git/hooks/pre-push
+ mv $LOCAL_HOOK $REPO_ROOT/.git/hooks/pre-push.old
+ echo "$REPO_ROOT/.git/hooks/pre-push.old" >> $REPO_ROOT/.git/hooks/pre-push
fi
fi
echo "$REPO_ROOT/cicd/pre-push.sh hook" >> $REPO_ROOT/.git/hooks/pre-push
chmod u+x $LOCAL_HOOK
-
}
(main)