From c011ff1a6cf2bd9c5391c4233504cce8074309c7 Mon Sep 17 00:00:00 2001 From: Daniel-GrunbergerCA Date: Sun, 19 Sep 2021 16:07:52 +0300 Subject: [PATCH] add scripts folder --- .github/workflows/export.yaml | 2 +- export.py => scripts/export.py | 0 scripts/generate_id.sh | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) rename export.py => scripts/export.py (100%) create mode 100755 scripts/generate_id.sh diff --git a/.github/workflows/export.yaml b/.github/workflows/export.yaml index 7b7d51dc4..8c275530c 100644 --- a/.github/workflows/export.yaml +++ b/.github/workflows/export.yaml @@ -41,7 +41,7 @@ jobs: python-version: 3.8 #install the python needed - name: execute py script # run the run.py to get the latest data run: | - python export.py + python ./scripts/export.py - name: Upload Release Asset id: upload-release-asset diff --git a/export.py b/scripts/export.py similarity index 100% rename from export.py rename to scripts/export.py diff --git a/scripts/generate_id.sh b/scripts/generate_id.sh new file mode 100755 index 000000000..79e336621 --- /dev/null +++ b/scripts/generate_id.sh @@ -0,0 +1,19 @@ +#!/bin/sh + + +# Generates new ID for controls. Run it when adding a new control and set the ouput as the 'id' field + + +# Get current highest id from all controls +HIGHEST_ID=$(grep \"id\": ../controls/*.json -h | cut -d "-" -f 2 | sort | tail -n1 | sed 's/"//g;s/0//g') + +NEW_ID=$(echo $(($HIGHEST_ID + 1))) + + +[ $NEW_ID -lt 10 ] && NEW_ID="0$NEW_ID" + +[ $NEW_ID -lt 100 ] && NEW_ID="0$NEW_ID" + +[ $NEW_ID -lt 1000 ] && NEW_ID="0$NEW_ID" + +echo "C-$NEW_ID" \ No newline at end of file