Skip to content

Commit 4459e30

Browse files
authored
E2e env actions keystore (#90)
* keystore-actions * act * --repo-update on pod install * keystore * android keystore configuration * ios signing * keystores * ios-crypto
1 parent d7a349b commit 4459e30

2 files changed

Lines changed: 120 additions & 1 deletion

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: "Configure Keystore"
2+
description: "Assume an AWS role and fetch a secret into environment variables"
3+
4+
inputs:
5+
aws-role-to-assume:
6+
description: "The AWS IAM role to assume"
7+
required: true
8+
aws-region:
9+
description: "The AWS region where the secret is stored"
10+
required: true
11+
secret-name:
12+
description: "The name of the secret in AWS Secrets Manager"
13+
required: true
14+
platform:
15+
description: "The platform for which the keystore is being configured (e.g., ios, android)"
16+
required: true
17+
environment:
18+
description: "The environment for which the keystore is being configured (e.g., qa, flask, main)"
19+
required: true
20+
21+
runs:
22+
using: "composite"
23+
steps:
24+
- name: Determine signing secret name
25+
shell: bash
26+
run: |
27+
case "${{ inputs.environment }}" in
28+
qa)
29+
SECRET_NAME="metamask-mobile-qa-signing-certificates"
30+
;;
31+
flask)
32+
SECRET_NAME="metamask-mobile-flask-signing-certificates"
33+
;;
34+
main)
35+
SECRET_NAME="metamask-mobile-main-signing-certificates"
36+
;;
37+
*)
38+
echo "❌ Unknown environment: ${{ inputs.environment }}"
39+
exit 1
40+
;;
41+
esac
42+
echo "AWS_SIGNING_CERT_SECRET_NAME=$SECRET_NAME" >> "$GITHUB_ENV"
43+
44+
- name: Configure AWS credentials
45+
uses: aws-actions/configure-aws-credentials@v4
46+
with:
47+
role-to-assume: ${{ inputs.aws-role-to-assume }}
48+
aws-region: ${{ inputs.aws-region }}
49+
50+
- name: Fetch secret and export as environment variables
51+
shell: bash
52+
run: |
53+
echo "🔐 Fetching secret from Secrets Manager..."
54+
secret_json=$(aws secretsmanager get-secret-value \
55+
--region "${{ inputs.aws-region }}" \
56+
--secret-id "${AWS_SIGNING_CERT_SECRET_NAME}" \
57+
--query SecretString \
58+
--output text)
59+
60+
keys=$(echo "$secret_json" | jq -r 'keys[]')
61+
for key in $keys; do
62+
value=$(echo "$secret_json" | jq -r --arg k "$key" '.[$k]')
63+
echo "::add-mask::$value"
64+
echo "$key=$(printf '%s' "$value")" >> "$GITHUB_ENV"
65+
echo "✅ Set secret for key: $key"
66+
done
67+
68+
- name: Configure Android Signing Certificates
69+
if: inputs.platform == 'android'
70+
shell: bash
71+
run: |
72+
echo "📦 Configuring Android keystore..."
73+
if [[ -z "$ANDROID_KEYSTORE" ]]; then
74+
echo "⚠️ ANDROID_KEYSTORE is not set. Skipping keystore decoding."
75+
exit 1
76+
fi
77+
78+
# Use provided path if set, fallback to default
79+
KEYSTORE_PATH="${ANDROID_KEYSTORE_PATH:-/tmp/android.keystore}"
80+
echo "$ANDROID_KEYSTORE" | base64 --decode > "$KEYSTORE_PATH"
81+
echo "✅ Android keystore written to $KEYSTORE_PATH"
82+
83+
- name: Configure iOS Signing Certificates
84+
if: inputs.platform == 'ios'
85+
shell: bash
86+
run: |
87+
echo "📦 Configuring iOS code signing..."
88+
89+
# Create paths
90+
CERT_PATH="$RUNNER_TEMP/build_certificate.p12"
91+
PROFILE_PATH="$RUNNER_TEMP/build_pp.mobileprovision"
92+
KEYCHAIN_PATH="$RUNNER_TEMP/app-signing.keychain-db"
93+
CERT_PW="${IOS_SIGNING_KEYSTORE_PASSWORD}"
94+
95+
# Decode base64 files
96+
echo "$IOS_SIGNING_KEYSTORE" | base64 --decode > "$CERT_PATH"
97+
echo "$IOS_SIGNING_PROFILE" | base64 --decode > "$PROFILE_PATH"
98+
echo "✅ Decoded .p12 and provisioning profile"
99+
100+
# Create and unlock keychain
101+
security create-keychain -p "$CERT_PW" "$KEYCHAIN_PATH"
102+
security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
103+
security unlock-keychain -p "$CERT_PW" "$KEYCHAIN_PATH"
104+
105+
# Import cert
106+
security import "$CERT_PATH" -P "$CERT_PW" -A -t cert -f pkcs12 -k "$KEYCHAIN_PATH" > /dev/null
107+
security set-key-partition-list -S apple-tool:,apple: -k "$CERT_PW" "$KEYCHAIN_PATH" > /dev/null
108+
security find-identity -p codesigning "$KEYCHAIN_PATH"
109+
110+
111+
# Install provisioning profile
112+
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
113+
cp "$PROFILE_PATH" ~/Library/MobileDevice/Provisioning\ Profiles/
114+
echo "✅ Installed provisioning profile"
115+

.github/actions/setup-e2e-env/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ inputs:
6969
description: 'System architecture ABI for the Android system image (e.g. x86_64, arm64-v8a, armeabi-v7a)'
7070
required: false
7171
default: 'x86_64'
72+
configure-keystores:
73+
description: 'Whether to configure keystores for E2E tests'
74+
required: false
75+
default: 'true'
7276

7377
runs:
7478
using: 'composite'
@@ -180,7 +184,7 @@ runs:
180184
# Install CocoaPods w/ cached bundler environment
181185
- name: Install CocoaPods via bundler
182186
if: ${{ inputs.platform == 'ios' && inputs.setup-simulator == 'true' }}
183-
run: bundle exec pod install
187+
run: bundle exec pod install --repo-update
184188
working-directory: ios
185189
shell: bash
186190

0 commit comments

Comments
 (0)