Skip to content

Commit

Permalink
Only write the ci files if the env var is declared.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWoitaschek committed Jul 2, 2023
1 parent 9705cd2 commit 40e35cd
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions ci_signing_setup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/bin/bash

if [ ! -d "signing/play" ]; then
mkdir -p signing/play
echo "$SIGNING_KEYSTORE_PLAY" | base64 --decode >signing/play/signing.keystore
echo "$SIGNING_PROPERTIES_PLAY" | base64 --decode >signing/play/signing.properties
fi
decode_env_to_file() {
local env_var="${1}"
local dest_file="${2}"
if [[ -n "${!env_var}" ]]; then
if [[ ! -f "${dest_file}" ]]; then
echo "${!env_var}" | base64 --decode >"${dest_file}"
echo "Success: Written to ${dest_file}"
else
echo "Warning: File ${dest_file} already exists, not overwritten."
fi
else
echo "Warning: Environment variable ${env_var} is empty or not set, no action taken."
fi
}

if [ ! -d "signing/github" ]; then
mkdir -p signing/github
echo "$SIGNING_KEYSTORE_GITHUB" | base64 --decode >signing/github/signing.keystore
echo "$SIGNING_PROPERTIES_GITHUB" | base64 --decode >signing/github/signing.properties
fi
mkdir -p signing/play
mkdir -p signing/github

if [ ! -f "app/google-services.json" ]; then
echo "$GOOGLE_SERVICES" | base64 --decode >app/google-services.json
fi
decode_env_to_file "SIGNING_KEYSTORE_PLAY" "signing/play/signing.keystore"
decode_env_to_file "SIGNING_PROPERTIES_PLAY" "signing/play/signing.properties"

decode_env_to_file "SIGNING_KEYSTORE_GITHUB" "signing/github/signing.keystore"
decode_env_to_file "SIGNING_PROPERTIES_GITHUB" "signing/github/signing.properties"

decode_env_to_file "GOOGLE_SERVICES" "app/google-services.json"

0 comments on commit 40e35cd

Please sign in to comment.