Skip to content

Commit be4eab0

Browse files
committed
Merge branch 'e2e-env-actions' into emulator-configs
2 parents c9a9b09 + a4d8ac3 commit be4eab0

2 files changed

Lines changed: 149 additions & 1 deletion

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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"

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ inputs:
6464
description: 'System architecture ABI for the Android system image (e.g. x86_64, arm64-v8a, armeabi-v7a)'
6565
required: false
6666
default: 'x86_64'
67+
configure-keystores:
68+
description: 'Whether to configure keystores for E2E tests'
69+
required: false
70+
default: 'true'
71+
keystore-role-to-assume:
72+
description: 'AWS IAM role to assume for keystore configuration'
73+
required: false
74+
default: 'arn:aws:iam::363762752069:role/metamask-mobile-build-signing-certificate-manager'
75+
environment:
76+
description: 'Environment for which the keystore is being configured (e.g., qa, flask, main)'
77+
required: false
78+
default: 'qa'
6779

6880
runs:
6981
using: 'composite'
@@ -72,6 +84,11 @@ runs:
7284
- run: echo "Setup E2E Environment started"
7385
shell: bash
7486

87+
- name: Setup Node.js
88+
uses: actions/setup-node@v4
89+
with:
90+
node-version: ${{ inputs.node-version }}
91+
7592
## Yarn Setup & Cache Management
7693

7794
- name: Corepack
@@ -118,6 +135,14 @@ runs:
118135
"$FOUNDRY_BIN/foundryup"
119136
120137
## IOS Setup ##
138+
- name: Configure iOS Signing Certificates
139+
if: ${{ inputs.platform == 'ios' && inputs.configure-keystores == 'true' }}
140+
uses: MetaMask/github-tools/.github/actions/configure-keystore@e2e-env-actions
141+
with:
142+
aws-role-to-assume: ${{ inputs.keystore-role-to-assume }}
143+
aws-region: 'us-east-2'
144+
platform: 'ios'
145+
environment: ${{ inputs.environment }}
121146

122147
## Ruby Setup & Cache Management
123148
- name: Setup Ruby
@@ -175,7 +200,7 @@ runs:
175200
# Install CocoaPods w/ cached bundler environment
176201
- name: Install CocoaPods via bundler
177202
if: ${{ inputs.platform == 'ios' && inputs.setup-simulator == 'true' }}
178-
run: bundle exec pod install
203+
run: bundle exec pod install --repo-update
179204
working-directory: ios
180205
shell: bash
181206

@@ -198,6 +223,15 @@ runs:
198223
with:
199224
java-version: ${{ inputs.jdk-version }}
200225
distribution: ${{ inputs.jdk-distribution }}
226+
227+
- name: Configure Android Signing Certificates
228+
if: ${{ inputs.platform == 'android' && inputs.configure-keystores == 'true' }}
229+
uses: MetaMask/github-tools/.github/actions/configure-keystore@e2e-env-actions
230+
with:
231+
aws-role-to-assume: ${{ inputs.keystore-role-to-assume }}
232+
aws-region: 'us-east-2'
233+
platform: 'android'
234+
environment: ${{ inputs.environment }}
201235

202236
- name: Enable KVM group perms (Ubuntu only)
203237
if: ${{ inputs.platform == 'android' && runner.os == 'Linux' }}

0 commit comments

Comments
 (0)