From 7ef38400e42bab0a66c1333c27d55d14cf7349d1 Mon Sep 17 00:00:00 2001 From: SoundDrill 31 Date: Fri, 2 Aug 2024 13:47:42 +0000 Subject: [PATCH 1/3] Add initial crave.conf checker script --- .github/workflows/main.yml | 6 ++++++ .github/workflows/selfhosted.yml | 6 ++++++ .github/workflows/twrp-legacy.yml | 6 ++++++ .github/workflows/twrp.yml | 6 ++++++ scripts/env-checker.sh | 35 +++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 scripts/env-checker.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8591951a..b9fa4f26 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -76,6 +76,12 @@ jobs: name: Prepare for Building runs-on: ubuntu-latest steps: + - name: Check-out to repository + uses: actions/checkout@v4 + + - name: Check Credentials + run: bash scripts/env-checker.sh + - name: Set Project variables id: proj-variables run: | diff --git a/.github/workflows/selfhosted.yml b/.github/workflows/selfhosted.yml index b6561855..4a4933d6 100644 --- a/.github/workflows/selfhosted.yml +++ b/.github/workflows/selfhosted.yml @@ -115,6 +115,12 @@ jobs: name: Prepare for Building runs-on: ubuntu-latest steps: + - name: Check-out to repository + uses: actions/checkout@v4 + + - name: Check Credentials + run: bash scripts/env-checker.sh + - name: Set Project variables id: proj-variables run: | diff --git a/.github/workflows/twrp-legacy.yml b/.github/workflows/twrp-legacy.yml index 36c59fc4..1d884065 100644 --- a/.github/workflows/twrp-legacy.yml +++ b/.github/workflows/twrp-legacy.yml @@ -67,6 +67,12 @@ jobs: name: Prepare for Building runs-on: ubuntu-latest steps: + - name: Check-out to repository + uses: actions/checkout@v4 + + - name: Check Credentials + run: bash scripts/env-checker.sh + - name: Display Run Parameters # Credit to azwhikaru for this part run: | echo "::group::User Environment Variables" diff --git a/.github/workflows/twrp.yml b/.github/workflows/twrp.yml index 9ed99c09..71405eec 100644 --- a/.github/workflows/twrp.yml +++ b/.github/workflows/twrp.yml @@ -67,6 +67,12 @@ jobs: name: Prepare for Building runs-on: ubuntu-latest steps: + - name: Check-out to repository + uses: actions/checkout@v4 + + - name: Check Credentials + run: bash scripts/env-checker.sh + - name: Display Run Parameters # Credit to azwhikaru for this part run: | echo "::group::User Environment Variables" diff --git a/scripts/env-checker.sh b/scripts/env-checker.sh new file mode 100644 index 00000000..6939ffa1 --- /dev/null +++ b/scripts/env-checker.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Check if file name is correct +if [ -f "crave.conf" ]; then + echo "Don't change crave.conf.sample! Exiting..." + exit 1 +fi + +# Check if crave.conf.sample exists +if [! -f "crave.conf.sample" ]; then + echo "crave.conf.sample doesn't exist!" + exit 1 +fi + +# Check if username has been altered +if! grep -q '"username": "${CRAVE_USERNAME}"' "crave.conf.sample"; then + echo "Don't add your username to crave.conf, use github secrets! Exiting..." + exit 1 +fi + +# Check if Authorization has been altered +if! grep -q '"Authorization": "${CRAVE_TOKEN}"' "crave.conf.sample"; then + echo "Don't add your token to crave.conf, use github secrets! Exiting..." + exit 1 +fi + +# Check if server is set to devspace.crave.io +if grep -q '"server": "https://devspace.crave.io/api"' "crave.conf.sample"; then + echo "Devspace.crave.io is the public instance and does not support building android!" + echo "Get a foss.crave.io account. To know more, read the docs: https://opendroid.pugzarecute.com/wiki/Crave_Devspace#getting-a-fosscraveiohttpsfosscraveio-account" + echo "Exiting..." + exit 1 +fi + +echo "crave.conf looks okay! Continuing..." \ No newline at end of file From 9846767da8dab2c1ef9ad1476fec1344b33671a1 Mon Sep 17 00:00:00 2001 From: SoundDrill 31 Date: Fri, 2 Aug 2024 13:48:41 +0000 Subject: [PATCH 2/3] Make vscode workflow obsolete Not needed anymore --- .github/workflows/{start-vscode.yml => start-vscode.obsolete} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{start-vscode.yml => start-vscode.obsolete} (100%) diff --git a/.github/workflows/start-vscode.yml b/.github/workflows/start-vscode.obsolete similarity index 100% rename from .github/workflows/start-vscode.yml rename to .github/workflows/start-vscode.obsolete From 5963b068491bf7e267d2d867e6a01ae3ecaa4cc0 Mon Sep 17 00:00:00 2001 From: SoundDrill 31 Date: Fri, 2 Aug 2024 13:52:23 +0000 Subject: [PATCH 3/3] env-checker: Escape the quotes and variables --- scripts/env-checker.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/env-checker.sh b/scripts/env-checker.sh index 6939ffa1..5d4692d8 100644 --- a/scripts/env-checker.sh +++ b/scripts/env-checker.sh @@ -1,31 +1,31 @@ #!/bin/bash -# Check if file name is correct -if [ -f "crave.conf" ]; then - echo "Don't change crave.conf.sample! Exiting..." +# Check if crave.conf.sample exists +if [ ! -f "crave.conf.sample" ]; then + echo "crave.conf.sample doesn't exist!" exit 1 fi -# Check if crave.conf.sample exists -if [! -f "crave.conf.sample" ]; then - echo "crave.conf.sample doesn't exist!" +# Check if file name is correct +if [ -f "crave.conf" ]; then + echo "Don't change crave.conf.sample! Exiting..." exit 1 fi # Check if username has been altered -if! grep -q '"username": "${CRAVE_USERNAME}"' "crave.conf.sample"; then +if ! grep -q "\"username\": \"\${CRAVE_USERNAME}\"" "crave.conf.sample"; then echo "Don't add your username to crave.conf, use github secrets! Exiting..." exit 1 fi # Check if Authorization has been altered -if! grep -q '"Authorization": "${CRAVE_TOKEN}"' "crave.conf.sample"; then +if ! grep -q "\"Authorization\": \"\${CRAVE_TOKEN}\"" "crave.conf.sample"; then echo "Don't add your token to crave.conf, use github secrets! Exiting..." exit 1 fi # Check if server is set to devspace.crave.io -if grep -q '"server": "https://devspace.crave.io/api"' "crave.conf.sample"; then +if grep -q "\"server\": \"https://devspace.crave.io/api\"" "crave.conf.sample"; then echo "Devspace.crave.io is the public instance and does not support building android!" echo "Get a foss.crave.io account. To know more, read the docs: https://opendroid.pugzarecute.com/wiki/Crave_Devspace#getting-a-fosscraveiohttpsfosscraveio-account" echo "Exiting..."