Skip to content

Commit

Permalink
Update build workflow to use secrets
Browse files Browse the repository at this point in the history
Signed-off-by: Kshitij Patil <[email protected]>
  • Loading branch information
Kshitij09 committed Nov 1, 2021
1 parent 290f7bd commit fc784d1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
16 changes: 14 additions & 2 deletions .github/workflows/tazabazar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30

env:
ORG_GRADLE_PROJECT_TAZABAZAR_RELEASE_PWD: ${{ secrets.ORG_GRADLE_PROJECT_TAZABAZAR_RELEASE_PWD }}

steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -21,6 +24,11 @@ jobs:
with:
java-version: 11

- name: Decrypt Release Keystore
env:
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
run: ./scripts/decrypt_secrets.sh

- name: Generate Cache key
run: ./scripts/checksum.sh checksum.txt

Expand All @@ -33,11 +41,14 @@ jobs:
key: gradle-${{ hashFiles('checksum.txt') }}

- name: Build Project
run: ./gradlew assembleDebug --stacktrace
run: ./gradlew assembleDebug assembleRelease --stacktrace

- name: Run Unit tests
run: ./gradlew test -Pprod --stacktrace

- name: Clean Secrets
run: ./scripts/clean_secrets.sh

- name: Upload build outputs (APKs)
uses: actions/upload-artifact@v2
with:
Expand All @@ -49,4 +60,5 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: build-reports
path: app/build/reports
path: app/build/reports

4 changes: 4 additions & 0 deletions scripts/clean_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

# Delete Release key
rm -rf signing/app-release.jks
17 changes: 17 additions & 0 deletions scripts/decrypt_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

decrypt() {
PASSPHRASE=$1
INPUT=$2
OUTPUT=$3
gpg --quiet --batch --yes --decrypt --passphrase="$PASSPHRASE" --output $OUTPUT $INPUT
}

if [[ ! -z "$ENCRYPT_KEY" ]]; then
# Decrypt Release key
decrypt ${ENCRYPT_KEY} signing/app-release.gpg signing/app-release.jks

else
echo "ENCRYPT_KEY is empty"
exit 22
fi

0 comments on commit fc784d1

Please sign in to comment.