From b63c5b784117444b81a9d523ac38c16238e4cb6d Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 27 Apr 2021 19:14:24 +0200 Subject: [PATCH] Completed the build path with set of gitHub user and secrets. Add all public domain versions in test. --- .github/workflows/build.yml | 24 +++-- .github/workflows/test.yml | 17 ++- conf/CrosswireModulesMapTest.json | 64 ++++++++++- src/setGithubUser.sh | 170 ++++++++++++++++++++++++++++++ 4 files changed, 263 insertions(+), 12 deletions(-) create mode 100755 src/setGithubUser.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 330e2e3..2b427e5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: "Build getBible static JSON API files" on: # run once per/day schedule: - - cron: '7 7 * * *' + - cron: '7 7 * * 3' # also run if we merge staging into master push: @@ -24,10 +24,22 @@ jobs: ref: master - name: Install Dependancies run: | - sudo apt install python3.8 python3-pip python3-requests + sudo apt install python3.8 python3-pip python3-requests tomb zsh zsh-common steghide sudo pip3 install future sudo pip3 install pysword -# not ready.... -# - name: Build the JSON Bible files -# run: | -# /bin/bash ./run.sh --github --pull --push \ No newline at end of file + - name: Setup gitHub User Details + env: + GIT_USER: ${{ secrets.GETBIBLE_GIT_USER }} + GIT_EMAIL: ${{ secrets.GETBIBLE_GIT_EMAIL }} + GPG_USER: ${{ secrets.GETBIBLE_GPG_USER }} + GPG_KEY: ${{ secrets.GETBIBLE_GPG_KEY }} + SSH_KEY: ${{ secrets.GETBIBLE_SSH_KEY }} + SSH_PUB: ${{ secrets.GETBIBLE_SSH_PUB }} + run: | + /bin/bash ./src/setGithubUser.sh --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" + - name: Build the JSON Bible files + env: + HASH_REPO: ${{ secrets.GETBIBLE_HASH_REPO }} + SCRIPTURE_REPO: ${{ secrets.GETBIBLE_SCRIPTURE_REPO }} + run: | + /bin/bash ./run.sh --github --pull --push --repo-hash="$HASH_REPO" --repo-scripture="$SCRIPTURE_REPO" \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 030d0b4..0ccc9b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,19 @@ jobs: sudo apt install python3.8 python3-pip python3-requests sudo pip3 install future sudo pip3 install pysword - - name: Build the JSON Bible files + - name: Setup gitHub User Details + env: + GIT_USER: ${{ secrets.GETBIBLE_GIT_USER }} + GIT_EMAIL: ${{ secrets.GETBIBLE_GIT_EMAIL }} + GPG_USER: ${{ secrets.GETBIBLE_GPG_USER }} + GPG_KEY: ${{ secrets.GETBIBLE_GPG_KEY }} + SSH_KEY: ${{ secrets.GETBIBLE_SSH_KEY }} + SSH_PUB: ${{ secrets.GETBIBLE_SSH_PUB }} run: | - /bin/bash ./run.sh --github --test \ No newline at end of file + /bin/bash ./src/setGithubUser.sh --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" + - name: Build the JSON Bible files + env: + HASH_REPO: ${{ secrets.GETBIBLE_HASH_REPO_T }} + SCRIPTURE_REPO: ${{ secrets.GETBIBLE_SCRIPTURE_REPO_T }} + run: | + /bin/bash ./run.sh --github --test --pull --push --repo-hash="$HASH_REPO" --repo-scripture="$SCRIPTURE_REPO" diff --git a/conf/CrosswireModulesMapTest.json b/conf/CrosswireModulesMapTest.json index 58eaea2..a86c11b 100644 --- a/conf/CrosswireModulesMapTest.json +++ b/conf/CrosswireModulesMapTest.json @@ -1,5 +1,61 @@ { - "Afr1953" : "aov", - "AraSVD" : "arabicsv", - "KJVA": "kjva" -} + "Peshitta" : "peshitta", + "ArmEastern" : "easternarmenian", + "ArmWestern" : "westernarmenian", + "BasHautin" : "basque", + "ChiUns" : "cus", + "ChiUn" : "cut", + "CopNT" : "coptic", + "CopSahHorner" : "sahidic", + "Cro" : "croatia", + "CzeBKR" : "bkr", + "DaOT1931NT1907" : "danish", + "DutSVV" : "statenvertaling", + "ASV" : "asv", + "BBE" : "basicenglish", + "DRC" : "douayrheims", + "KJV" : "kjv", + "KJVA": "kjva", + "Webster" : "wb", + "Weymouth" : "weymouth", + "WEB" : "web", + "Tyndale": "tyndale", + "YLT" : "ylt", + "Wycliffe" : "wycliffe", + "Esperanto" : "esperanto", + "FinBiblia" : "finnish1776", + "FinPR" : "pyharaamattu1933", + "FreJND" : "darby", + "FreMartin" : "martin", + "GerElb1871" : "elberfelder", + "GerElb1905" : "elberfelder1905", + "GerLut1545" : "luther1545", + "Wulfila" : "gothic", + "GreVamvas" : "moderngreek", + "TR" : "textusreceptus", + "Tisch" : "tischendorf", + "WHNU" : "westcotthort", + "Aleppo" : "aleppo", + "HebModern" : "modernhebrew", + "WLC" : "codex", + "HunKar" : "karoli", + "ItaDio" : "giovanni", + "ItaRive" : "riveduta", + "KorRV" : "korean", + "VulgClementine" : "vulgate", + "Mal1910" : "mal1910", + "ManxGaelic" : "manxgaelic", + "BurJudson" : "judson", + "Norsk" : "bibelselskap", + "PorAR" : "almeida", + "PotLykins" : "potawatomi", + "RusSynodal" : "synodal", + "ScotsGaelic" : "gaelic", + "SpaRV" : "rv1858", + "SpaRV1865" : "sse", + "Swahili" : "swahili", + "Swe1917" : "swedish", + "TagAngBiblia" : "tagalog", + "UkrKulish" : "ukranian", + "Viet" : "vietnamese" +} \ No newline at end of file diff --git a/src/setGithubUser.sh b/src/setGithubUser.sh new file mode 100755 index 0000000..0da580a --- /dev/null +++ b/src/setGithubUser.sh @@ -0,0 +1,170 @@ +#! /bin/bash + +# DEFAULTS/GLOBALS +GPG_KEY="" +GPG_USER="" +SSH_KEY="" +SSH_PUB="" +GIT_USER="" +GIT_EMAIL="" + +# check if we have options +while :; do + case $1 in + --gpg-key) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + GPG_KEY=$2 + shift + else + echo 'ERROR: "--gpg-key" requires a non-empty option argument.' + exit 1 + fi + ;; + --gpg-key=?*) + GPG_KEY=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --gpg-key=) # Handle the case of an empty --gpg-key= + echo 'ERROR: "--gpg-key" requires a non-empty option argument.' + exit 1 + ;; + --gpg-user) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + GPG_USER=$2 + shift + else + echo 'ERROR: "--gpg-user" requires a non-empty option argument.' + exit 1 + fi + ;; + --gpg-user=?*) + GPG_USER=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --gpg-user=) # Handle the case of an empty --gpg-user= + echo 'ERROR: "--gpg-user" requires a non-empty option argument.' + exit 1 + ;; + --ssh-key) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + SSH_KEY=$2 + shift + else + echo 'ERROR: "--ssh-key" requires a non-empty option argument.' + exit 1 + fi + ;; + --ssh-key=?*) + SSH_KEY=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --ssh-key=) # Handle the case of an empty --ssh-key= + echo 'ERROR: "--ssh-key" requires a non-empty option argument.' + exit 1 + ;; + --ssh-pub) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + SSH_PUB=$2 + shift + else + echo 'ERROR: "--ssh-pub" requires a non-empty option argument.' + exit 1 + fi + ;; + --ssh-pub=?*) + SSH_PUB=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --ssh-pub=) # Handle the case of an empty --ssh-pub= + echo 'ERROR: "--ssh-pub" requires a non-empty option argument.' + exit 1 + ;; + --git-user) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + GIT_USER=$2 + shift + else + echo 'ERROR: "--git-user" requires a non-empty option argument.' + exit 1 + fi + ;; + --git-user=?*) + GIT_USER=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --git-user=) # Handle the case of an empty --git-user= + echo 'ERROR: "--git-user" requires a non-empty option argument.' + exit 1 + ;; + --git-email) # Takes an option argument; ensure it has been specified. + if [ "$2" ]; then + GIT_EMAIL=$2 + shift + else + echo 'ERROR: "--git-email" requires a non-empty option argument.' + exit 1 + fi + ;; + --git-email=?*) + GIT_EMAIL=${1#*=} # Delete everything up to "=" and assign the remainder. + ;; + --git-email=) # Handle the case of an empty --git-email= + echo 'ERROR: "--git-email" requires a non-empty option argument.' + exit 1 + ;; + *) # Default case: No more options, so break out of the loop. + break ;; + esac + shift +done + +# We must sign all git push events +if [ -z "${GPG_KEY}" ]; then + echo >&2 "The GPG_KEY:${GPG_KEY} is not set. Aborting." + exit 1 +else + # place the secret in the open to github... where it is anyway. + echo "${GPG_KEY}" >robot.asc + # add the key to the system + gpg --import robot.asc +fi + +# To set the github signingkey we need to get the gpg key id with the key user name +if [ -z "${GPG_USER}" ]; then + echo >&2 "The GPG_USER:${GPG_USER} is not set. Aborting." + exit 1 +else + # get the gpg signingkey ID + git_signingkey=$(gpg --list-signatures --with-colons | grep 'sig' | grep "${GPG_USER}" | head -n 1 | cut -d':' -f5) +fi + +# make the ssh dir +mkdir -p ~/.ssh + +# we need to set the SSH key to push/pull to/from github +if [ -z "${SSH_KEY}" ]; then + echo >&2 "The SSH_KEY is not set. Aborting." + exit 1 +fi +if [ -z "${SSH_PUB}" ]; then + echo >&2 "The SSH_PUB is not set. Aborting." + exit 1 +fi + +# move the keys into place (check the type!) +echo "${SSH_KEY}" >~/.ssh/id_ed25519 +echo "${SSH_PUB}" >~/.ssh/id_ed25519.pub + +# set the protection of the key files +chmod 400 ~/.ssh/id_ed25519 +chmod 400 ~/.ssh/id_ed25519.pub + +# We need the git user name/email set to access github +if [ -z "${GIT_USER}" ]; then + echo >&2 "The GIT_USER is not set. Aborting." + exit 1 +fi +if [ -z "${GIT_EMAIL}" ]; then + echo >&2 "The GIT_EMAIL is not set. Aborting." + exit 1 +fi + +# set the github user details +git config --global user.name "${GIT_USER}" +git config --global user.email "${GIT_EMAIL}" +git config --global user.signingkey "$git_signingkey"