Skip to content

Commit f4b2aa8

Browse files
authored
fix: Use environment variables for script inputs in all workflows (#162)
* Use environment variables for script inputs in all workflows * Fix broken command * Fix lint workflow * Add missing ID * Add `--activate` back
1 parent 7b583a3 commit f4b2aa8

File tree

10 files changed

+142
-87
lines changed

10 files changed

+142
-87
lines changed

.github/actions/checkout-and-setup/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ runs:
2828
steps:
2929
# The "required: true" field is not enforced by GitHub, so we need to check it manually
3030
- name: Enforce required input is either "true" or "false"
31+
env:
32+
IS_HIGH_RISK_ENVIRONMENT: ${{ inputs.is-high-risk-environment }}
3133
run: |
32-
if [[ "${{ inputs.is-high-risk-environment }}" == "true" ]]; then
34+
if [[ "$IS_HIGH_RISK_ENVIRONMENT" == "true" ]]; then
3335
echo 'High-risk environment detected. Disabling cache for security.'
34-
elif [[ "${{ inputs.is-high-risk-environment }}" == "false" ]]; then
36+
elif [[ "$IS_HIGH_RISK_ENVIRONMENT" == "false" ]]; then
3537
echo 'Low-risk environment detected. Enabling cache for optimized performance.'
3638
else
3739
echo "::error::Invalid value for 'is-high-risk-environment'. Must be 'true' (secure, no cache) or 'false' (faster, cache enabled)."

.github/actions/configure-keystore/action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ runs:
2020
steps:
2121
- name: Determine signing secret name
2222
shell: bash
23+
env:
24+
TARGET: ${{ inputs.target }}
2325
run: |
24-
case "${{ inputs.target }}" in
26+
case "$TARGET" in
2527
qa)
2628
SECRET_NAME="metamask-mobile-qa-signing-certificates"
2729
;;
@@ -32,7 +34,7 @@ runs:
3234
SECRET_NAME="metamask-mobile-main-signing-certificates"
3335
;;
3436
*)
35-
echo "❌ Unknown target: ${{ inputs.target }}"
37+
echo "❌ Unknown target: $TARGET"
3638
exit 1
3739
;;
3840
esac
@@ -46,10 +48,12 @@ runs:
4648

4749
- name: Fetch secret and export as environment variables
4850
shell: bash
51+
env:
52+
AWS_REGION: ${{ inputs.aws-region }}
4953
run: |
5054
echo "🔐 Fetching secret from Secrets Manager..."
5155
secret_json=$(aws secretsmanager get-secret-value \
52-
--region "${{ inputs.aws-region }}" \
56+
--region "$AWS_REGION" \
5357
--secret-id "${AWS_SIGNING_CERT_SECRET_NAME}" \
5458
--query SecretString \
5559
--output text)

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

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ runs:
133133

134134
- name: Install additional Android SDK components if needed
135135
if: ${{ inputs.platform == 'android' && (inputs.android-api-level != '34' || inputs.android-abi != 'x86_64') }}
136+
env:
137+
ANDROID_API_LEVEL: ${{ inputs.android-api-level }}
138+
ANDROID_ABI: ${{ inputs.android-abi }}
136139
run: |
137140
# Only install if different from pre-installed defaults (API 34, x86_64)
138-
IMAGE="system-images;android-${{ inputs.android-api-level }};google_apis;${{ inputs.android-abi }}"
141+
IMAGE="system-images;android-$ANDROID_API_LEVEL;google_apis;$ANDROID_ABI"
139142
echo "Installing additional system image: $IMAGE"
140143
echo "y" | "/opt/android-sdk/cmdline-tools/latest/bin/sdkmanager" "$IMAGE"
141144
shell: bash
@@ -151,17 +154,24 @@ runs:
151154
152155
- name: Create Android Virtual Device (AVD)
153156
if: ${{ inputs.platform == 'android'}}
157+
env:
158+
ANDROID_API_LEVEL: ${{ inputs.android-api-level }}
159+
ANDROID_TAG: ${{ inputs.android-tag }}
160+
ANDROID_ABI: ${{ inputs.android-abi }}
161+
ANDROID_AVD_NAME: ${{ inputs.android-avd-name }}
162+
ANDROID_DEVICE: ${{ inputs.android-device }}
163+
ANDROID_SDCARD_SIZE: ${{ inputs.android-sdcard-size }}
154164
run: |
155-
IMAGE="system-images;android-${{ inputs.android-api-level }};${{ inputs.android-tag }};${{ inputs.android-abi }}"
165+
IMAGE="system-images;android-$ANDROID_API_LEVEL;$ANDROID_TAG;$ANDROID_ABI"
156166
echo "Creating AVD with image: $IMAGE"
157167
"/opt/android-sdk/cmdline-tools/latest/bin/avdmanager" --verbose create avd \
158168
--force \
159-
--name "${{ inputs.android-avd-name }}" \
169+
--name "$ANDROID_AVD_NAME" \
160170
--package "$IMAGE" \
161-
--device "${{ inputs.android-device }}" \
162-
--tag "${{ inputs.android-tag }}" \
163-
--abi "${{ inputs.android-abi }}" \
164-
--sdcard "${{ inputs.android-sdcard-size }}"
171+
--device "$ANDROID_DEVICE" \
172+
--tag "$ANDROID_TAG" \
173+
--abi "$ANDROID_ABI" \
174+
--sdcard "$ANDROID_SDCARD_SIZE"
165175
shell: bash
166176

167177
## iOS Platform Setup ##
@@ -184,10 +194,13 @@ runs:
184194

185195
## Yarn Setup & Cache Management
186196

187-
# - name: Corepack
188-
# id: corepack
189-
# run: corepack enable && corepack prepare yarn@${{ inputs.yarn-version }} --activate
190-
# shell: bash
197+
- name: Get Corepack install command
198+
id: get-corepack-command
199+
env:
200+
YARN_VERSION: ${{ inputs.yarn-version }}
201+
shell: bash
202+
run: |
203+
echo "COREPACK_COMMAND=corepack enable && corepack prepare yarn@$YARN_VERSION --activate" >> "$GITHUB_OUTPUT"
191204
192205
- name: Corepack
193206
id: corepack
@@ -196,7 +209,7 @@ runs:
196209
timeout_minutes: 15
197210
max_attempts: 3
198211
retry_wait_seconds: 30
199-
command: corepack enable && corepack prepare yarn@${{ inputs.yarn-version }} --activate
212+
command: ${{ steps.get-corepack-command.outputs.COREPACK_COMMAND }}
200213

201214
- name: Restore Yarn cache
202215
uses: actions/cache@v4
@@ -220,6 +233,8 @@ runs:
220233

221234
- name: Install Foundry
222235
shell: bash
236+
env:
237+
FOUNDRY_VERSION: ${{ inputs.foundry-version }}
223238
run: |
224239
echo "Installing Foundry via foundryup..."
225240
@@ -233,7 +248,7 @@ runs:
233248
234249
echo "$FOUNDRY_BIN" >> "$GITHUB_PATH"
235250
236-
"$FOUNDRY_BIN/foundryup" -i "${{ inputs.foundry-version }}"
251+
"$FOUNDRY_BIN/foundryup" -i "$FOUNDRY_VERSION"
237252
238253
## IOS Setup ##
239254

@@ -308,19 +323,11 @@ runs:
308323
# Select Xcode version
309324
- name: Select Xcode version
310325
if: ${{ inputs.platform == 'ios' }}
311-
run: sudo xcode-select -s /Applications/Xcode_${{ inputs.xcode-version }}.app
326+
env:
327+
XCODE_VERSION: ${{ inputs.xcode-version }}
328+
run: sudo xcode-select -s "/Applications/Xcode_$XCODE_VERSION.app"
312329
shell: bash
313330

314-
# Restore CocoaPods cache
315-
# - name: Restore CocoaPods cache
316-
# if: ${{ inputs.platform == 'ios'}}
317-
# uses: actions/cache@v4
318-
# with:
319-
# path: ios/Pods
320-
# key: ${{ inputs.cache-prefix }}-pods-${{ inputs.platform }}-${{ runner.os }}-${{ hashFiles('ios/Podfile.lock') }}
321-
# restore-keys: |
322-
# ${{ inputs.cache-prefix }}-pods-${{ inputs.platform }}-${{ runner.os }}-
323-
324331
# Install CocoaPods w/ cached bundler environment
325332
- name: Install CocoaPods via bundler
326333
if: ${{ inputs.platform == 'ios'}}

.github/actions/upload-s3/action.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ runs:
2626
role-to-assume: ${{ inputs.role-to-assume }}
2727

2828
- name: Upload to S3
29+
env:
30+
UPLOAD_PATH: ${{ inputs.path }}
31+
S3_BUCKET: ${{ inputs.s3-bucket }}
32+
2933
run: |
30-
if [ -d "${{ inputs.path }}" ]; then
31-
aws s3 cp "${{ inputs.path }}" "s3://${{ inputs.s3-bucket }}" --recursive
34+
if [ -d "$UPLOAD_PATH" ]; then
35+
aws s3 cp "$UPLOAD_PATH" "s3://$S3_BUCKET" --recursive
3236
else
33-
aws s3 cp "${{ inputs.path }}" "s3://${{ inputs.s3-bucket }}"
37+
aws s3 cp "$UPLOAD_PATH" "s3://$S3_BUCKET"
3438
fi
3539
shell: bash

.github/workflows/create-release-pr.yml

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -101,24 +101,38 @@ jobs:
101101

102102
# Step 4: Print Input Values
103103
- name: Print Input Values
104+
env:
105+
PLATFORM: ${{ inputs.platform }}
106+
CHECKOUT_BASE_BRANCH: ${{ inputs.checkout-base-branch }}
107+
RELEASE_PR_BASE_BRANCH: ${{ inputs.release-pr-base-branch }}
108+
SEMVER_VERSION: ${{ inputs.semver-version }}
109+
PREVIOUS_VERSION_REF: ${{ inputs.previous-version-ref }}
110+
TEST_ONLY: ${{ inputs.test-only }}
111+
MOBILE_BUILD_VERSION: ${{ inputs.mobile-build-version }}
112+
MOBILE_TEMPLATE_SHEET_ID: ${{ inputs.mobile-template-sheet-id }}
113+
EXTENSION_TEMPLATE_SHEET_ID: ${{ inputs.extension-template-sheet-id }}
114+
RELEASE_SHEET_GOOGLE_DOCUMENT_ID: ${{ inputs.release-sheet-google-document-id }}
115+
GITHUB_TOOLS_VERSION: ${{ inputs.github-tools-version }}
116+
GIT_USER_NAME: ${{ inputs.git-user-name }}
117+
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
104118
run: |
105119
echo "Input Values:"
106120
echo "-------------"
107-
echo "Platform: ${{ inputs.platform }}"
108-
echo "Checkout Base Branch: ${{ inputs.checkout-base-branch }}"
109-
echo "Release PR Base Branch: ${{ inputs.release-pr-base-branch }}"
110-
echo "Semver Version: ${{ inputs.semver-version }}"
111-
echo "Previous Version Reference: ${{ inputs.previous-version-ref }}"
112-
echo "Test Only Mode: ${{ inputs.test-only }}"
113-
if [[ "${{ inputs.platform }}" == "mobile" ]]; then
114-
echo "Mobile Build Version: ${{ inputs.mobile-build-version }}"
121+
echo "Platform: $PLATFORM"
122+
echo "Checkout Base Branch: $CHECKOUT_BASE_BRANCH"
123+
echo "Release PR Base Branch: $RELEASE_PR_BASE_BRANCH"
124+
echo "Semver Version: $SEMVER_VERSION"
125+
echo "Previous Version Reference: $PREVIOUS_VERSION_REF"
126+
echo "Test Only Mode: $TEST_ONLY"
127+
if [[ "$PLATFORM" == "mobile" ]]; then
128+
echo "Mobile Build Version: $MOBILE_BUILD_VERSION"
115129
fi
116-
echo "Mobile Template Sheet ID: ${{ inputs.mobile-template-sheet-id }}"
117-
echo "Extension Template Sheet ID: ${{ inputs.extension-template-sheet-id }}"
118-
echo "Release Sheet Google Document ID: ${{ inputs.release-sheet-google-document-id }}"
119-
echo "GitHub Tools Version: ${{ inputs.github-tools-version }}"
120-
echo "Git User Name: ${{ inputs.git-user-name }}"
121-
echo "Git User Email: ${{ inputs.git-user-email }}"
130+
echo "Mobile Template Sheet ID: $MOBILE_TEMPLATE_SHEET_ID"
131+
echo "Extension Template Sheet ID: $EXTENSION_TEMPLATE_SHEET_ID"
132+
echo "Release Sheet Google Document ID: $RELEASE_SHEET_GOOGLE_DOCUMENT_ID"
133+
echo "GitHub Tools Version: $GITHUB_TOOLS_VERSION"
134+
echo "Git User Name: $GIT_USER_NAME"
135+
echo "Git User Email: $GIT_USER_EMAIL"
122136
echo "-------------"
123137
124138
# Step 5: Create Release PR
@@ -135,16 +149,22 @@ jobs:
135149
NEW_VERSION: ${{ inputs.semver-version }}
136150
MOBILE_TEMPLATE_SHEET_ID: ${{ inputs.mobile-template-sheet-id }}
137151
EXTENSION_TEMPLATE_SHEET_ID: ${{ inputs.extension-template-sheet-id }}
152+
PLATFORM: ${{ inputs.platform }}
153+
PREVIOUS_VERSION_REF: ${{ inputs.previous-version-ref }}
154+
SEMVER_VERSION: ${{ inputs.semver-version }}
155+
MOBILE_BUILD_VERSION: ${{ inputs.mobile-build-version }}
156+
GIT_USER_NAME: ${{ inputs.git-user-name }}
157+
GIT_USER_EMAIL: ${{ inputs.git-user-email }}
138158
working-directory: ${{ github.workspace }}
139159
run: |
140160
# Execute the script from github-tools
141161
./github-tools/.github/scripts/create-platform-release-pr.sh \
142-
"${{ inputs.platform }}" \
143-
"${{ inputs.previous-version-ref }}" \
144-
"${{ inputs.semver-version }}" \
145-
"${{ inputs.mobile-build-version }}" \
146-
"${{ inputs.git-user-name }}" \
147-
"${{ inputs.git-user-email }}"
162+
"$PLATFORM" \
163+
"$PREVIOUS_VERSION_REF" \
164+
"$SEMVER_VERSION" \
165+
"$MOBILE_BUILD_VERSION" \
166+
"$GIT_USER_NAME" \
167+
"$GIT_USER_EMAIL"
148168
149169
# Step 6: Upload commits.csv as artifact (if generated)
150170
- name: Upload commits.csv artifact

.github/workflows/lint-workflows.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
shell: bash
1818

1919
- name: Lint workflow files
20+
env:
21+
EXECUTABLE: ${{ steps.download-actionlint.outputs.executable }}
2022
# We need to ignore the expected missing inputs in test-checkout-and-setup.yml
21-
run: ${{ steps.download-actionlint.outputs.executable }} -color
23+
run: |
24+
"$EXECUTABLE" -color
2225
shell: bash

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ jobs:
4040
needs: all-jobs-completed
4141
steps:
4242
- name: Check that all jobs have passed
43+
env:
44+
PASSED: ${{ needs.all-jobs-completed.outputs.PASSED }}
4345
run: |
44-
passed="${{ needs.all-jobs-completed.outputs.PASSED }}"
45-
if [[ $passed != "true" ]]; then
46+
if [[ "$PASSED" != "true" ]]; then
4647
exit 1
4748
fi

.github/workflows/pr-line-check.yml

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,13 @@ jobs:
4646
- name: Checkout code
4747
uses: actions/checkout@v4
4848

49-
- name: Determine base branch
50-
id: get-base-branch
51-
run: |
52-
# Use the PR base branch if available; otherwise use the default input.
53-
if [ -n "${{ github.event.pull_request.base.ref }}" ]; then
54-
echo "Using PR base branch: ${{ github.event.pull_request.base.ref }}"
55-
echo "base_branch=${{ github.event.pull_request.base.ref }}" >> "$GITHUB_OUTPUT"
56-
else
57-
echo "Using default base branch: ${{ inputs.base_ref }}"
58-
echo "base_branch=${{ inputs.base_ref }}" >> "$GITHUB_OUTPUT"
59-
fi
60-
6149
- name: Calculate changed lines
6250
id: line_count
51+
env:
52+
BASE_BRANCH: ${{ github.event.pull_request.base.ref || inputs.base_ref }}
6353
run: |
6454
set -e
6555
66-
BASE_BRANCH="${{ steps.get-base-branch.outputs.base_branch }}"
6756
echo "Using base branch: $BASE_BRANCH"
6857
6958
# Instead of a full fetch, perform incremental fetches at increasing depth
@@ -112,18 +101,38 @@ jobs:
112101
113102
- name: Check line count limit
114103
uses: actions/github-script@v7
104+
env:
105+
LINES_CHANGED: ${{ steps.line_count.outputs.lines_changed }}
106+
ADDITIONS: ${{ steps.line_count.outputs.additions }}
107+
DELETIONS: ${{ steps.line_count.outputs.deletions }}
108+
MAX_LINES: ${{ inputs.max_lines }}
109+
XS_MAX_SIZE: ${{ inputs.xs_max_size }}
110+
S_MAX_SIZE: ${{ inputs.s_max_size }}
111+
M_MAX_SIZE: ${{ inputs.m_max_size }}
112+
L_MAX_SIZE: ${{ inputs.l_max_size }}
115113
with:
116114
script: |
117-
const total = parseInt('${{ steps.line_count.outputs.lines_changed }}') || 0;
118-
const additions = parseInt('${{ steps.line_count.outputs.additions }}') || 0;
119-
const deletions = parseInt('${{ steps.line_count.outputs.deletions }}') || 0;
115+
const {
116+
LINES_CHANGED,
117+
ADDITIONS,
118+
DELETIONS,
119+
MAX_LINES,
120+
XS_MAX_SIZE,
121+
S_MAX_SIZE,
122+
M_MAX_SIZE,
123+
L_MAX_SIZE,
124+
} = process.env;
125+
126+
const total = parseInt(LINES_CHANGED, 10) || 0;
127+
const additions = parseInt(ADDITIONS, 10) || 0;
128+
const deletions = parseInt(DELETIONS, 10) || 0;
120129
121130
// Thresholds from inputs with fallback to defaults
122-
const maxLines = parseInt('${{ inputs.max_lines }}') || 1000;
123-
const xsMaxSize = parseInt('${{ inputs.xs_max_size }}') || 10;
124-
const sMaxSize = parseInt('${{ inputs.s_max_size }}') || 100;
125-
const mMaxSize = parseInt('${{ inputs.m_max_size }}') || 500;
126-
const lMaxSize = parseInt('${{ inputs.l_max_size }}') || 1000;
131+
const maxLines = parseInt(MAX_LINES, 10) || 1000;
132+
const xsMaxSize = parseInt(XS_MAX_SIZE, 10) || 10;
133+
const sMaxSize = parseInt(S_MAX_SIZE, 10) || 100;
134+
const mMaxSize = parseInt(M_MAX_SIZE, 10) || 500;
135+
const lMaxSize = parseInt(L_MAX_SIZE, 10) || 1000;
127136
128137
// Print summary
129138
console.log('Summary:');
@@ -155,21 +164,21 @@ jobs:
155164
156165
try {
157166
const existingSizeLabels = ['size-XS', 'size-S', 'size-M', 'size-L', 'size-XL'];
158-
167+
159168
// Get current labels
160169
const currentLabels = await github.rest.issues.listLabelsOnIssue({
161170
owner,
162171
repo,
163172
issue_number
164173
});
165-
174+
166175
const currentLabelNames = currentLabels.data.map(l => l.name);
167-
176+
168177
// Build new label set: keep non-size labels and add the new size label
169178
const newLabels = currentLabelNames
170179
.filter(name => !existingSizeLabels.includes(name)) // Remove all size labels
171180
.concat(sizeLabel); // Add the correct size label
172-
181+
173182
// Check if labels need updating
174183
const currentSizeLabel = currentLabelNames.find(name => existingSizeLabels.includes(name));
175184
if (currentSizeLabel === sizeLabel && currentLabelNames.length === newLabels.length) {
@@ -182,7 +191,7 @@ jobs:
182191
issue_number,
183192
labels: newLabels
184193
});
185-
194+
186195
if (currentSizeLabel && currentSizeLabel !== sizeLabel) {
187196
console.log(` - Replaced '${currentSizeLabel}' with '${sizeLabel}'`);
188197
} else if (!currentSizeLabel) {

0 commit comments

Comments
 (0)