Skip to content

Commit ae5bd7c

Browse files
committed
move repeated actions to usable actions
1 parent eb4cf39 commit ae5bd7c

4 files changed

Lines changed: 83 additions & 78 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ app/core/Engine/controllers/remote-feature-flag-controller/ @MetaMask/mobile-pla
4444
app/core/DeeplinkManager @MetaMask/mobile-platform
4545
scripts/build.sh @MetaMask/mobile-platform
4646
fingerprint.config.js @MetaMask/mobile-platform
47+
.github/workflows/push-eas-update.yml @MetaMask/mobile-admins
4748
scripts/update-expo-channel.js @MetaMask/mobile-admins
4849
certs/certificate.pem @MetaMask/mobile-admins
4950
ios/fastlane/ @MetaMask/mobile-admins
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Restore Node Modules Executable Permissions'
2+
description: 'Restores executable permissions for node_modules binaries after artifact download'
3+
4+
inputs:
5+
working-directory:
6+
description: 'Working directory where node_modules is located'
7+
required: false
8+
default: '.'
9+
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Restore executable permissions
14+
shell: bash
15+
working-directory: ${{ inputs.working-directory }}
16+
run: |
17+
echo "🔧 Restoring executable permissions..."
18+
find node_modules/.bin -type f -exec chmod +x {} \; 2>/dev/null || true
19+
find node_modules -type f -name "*.node" -exec chmod +x {} \; 2>/dev/null || true
20+
find node_modules -path "*/bin/*" -type f -exec chmod +x {} \; 2>/dev/null || true
21+
find node_modules -path "*/sdks/*" -type f -exec chmod +x {} \; 2>/dev/null || true
22+
echo "✅ Permissions restored"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 'Validate Artifact Compatibility'
2+
description: 'Validates that the artifact was built with compatible Node version and OS'
3+
4+
inputs:
5+
artifact-name:
6+
description: 'The actual artifact name to validate'
7+
required: true
8+
artifact-prefix:
9+
description: 'The expected artifact prefix (e.g., node-modules-eas-update-pr or node-modules-eas-update-base)'
10+
required: true
11+
validation-context:
12+
description: 'Description of what is being validated (e.g., "PR commit", "base branch")'
13+
required: false
14+
default: 'artifact'
15+
16+
runs:
17+
using: 'composite'
18+
steps:
19+
- name: Validate artifact compatibility
20+
shell: bash
21+
run: |
22+
NODE_VERSION=$(node --version | sed 's/v//')
23+
OS_NAME=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
24+
EXPECTED_ARTIFACT="${{ inputs.artifact-prefix }}-node${NODE_VERSION}-${OS_NAME}"
25+
26+
echo "🔍 Validating ${{ inputs.validation-context }} artifact compatibility..."
27+
echo " Expected artifact: $EXPECTED_ARTIFACT"
28+
echo " Actual artifact: ${{ inputs.artifact-name }}"
29+
30+
if [ "$EXPECTED_ARTIFACT" != "${{ inputs.artifact-name }}" ]; then
31+
echo "::error title=Artifact Incompatibility::Node version or OS mismatch detected!"
32+
echo "❌ The node_modules artifact was built with different Node version or OS"
33+
echo " This could cause issues with native node modules"
34+
echo " Expected: $EXPECTED_ARTIFACT"
35+
echo " Actual: ${{ inputs.artifact-name }}"
36+
exit 1
37+
fi
38+
echo "✅ ${{ inputs.validation-context }} artifact compatibility validated"

.github/workflows/push-eas-update.yml

Lines changed: 22 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -98,38 +98,19 @@ jobs:
9898
node-version: '20'
9999

100100
- name: Validate artifact compatibility (PR commit)
101-
run: |
102-
NODE_VERSION=$(node --version | sed 's/v//')
103-
OS_NAME=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
104-
EXPECTED_ARTIFACT="node-modules-eas-update-pr-node${NODE_VERSION}-${OS_NAME}"
105-
106-
echo "🔍 Validating PR artifact compatibility..."
107-
echo " Expected artifact: $EXPECTED_ARTIFACT"
108-
echo " Actual artifact: ${{ env.PR_ARTIFACT_NAME }}"
109-
110-
if [ "$EXPECTED_ARTIFACT" != "${{ env.PR_ARTIFACT_NAME }}" ]; then
111-
echo "::error title=Artifact Incompatibility::Node version or OS mismatch detected!"
112-
echo "❌ The node_modules artifact was built with different Node version or OS"
113-
echo " This could cause issues with native node modules"
114-
echo " Expected: $EXPECTED_ARTIFACT"
115-
echo " Actual: ${{ env.PR_ARTIFACT_NAME }}"
116-
exit 1
117-
fi
118-
echo "✅ PR artifact compatibility validated"
101+
uses: ./.github/actions/validate-artifact-compatibility
102+
with:
103+
artifact-name: ${{ env.PR_ARTIFACT_NAME }}
104+
artifact-prefix: node-modules-eas-update-pr
105+
validation-context: PR commit
119106

120107
- name: Download node_modules artifact (PR commit)
121108
uses: actions/download-artifact@v4
122109
with:
123110
name: ${{ env.PR_ARTIFACT_NAME }}
124111

125112
- name: Restore executable permissions
126-
run: |
127-
echo "🔧 Restoring executable permissions..."
128-
find node_modules/.bin -type f -exec chmod +x {} \; 2>/dev/null || true
129-
find node_modules -type f -name "*.node" -exec chmod +x {} \; 2>/dev/null || true
130-
find node_modules -path "*/bin/*" -type f -exec chmod +x {} \; 2>/dev/null || true
131-
find node_modules -path "*/sdks/*" -type f -exec chmod +x {} \; 2>/dev/null || true
132-
echo "✅ Permissions restored"
113+
uses: ./.github/actions/restore-node-modules-permissions
133114

134115
- name: Verify downloaded artifacts
135116
run: |
@@ -153,24 +134,11 @@ jobs:
153134
echo "Target PR fingerprint: $FINGERPRINT"
154135
155136
- name: Validate artifact compatibility (base branch)
156-
run: |
157-
NODE_VERSION=$(node --version | sed 's/v//')
158-
OS_NAME=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
159-
EXPECTED_ARTIFACT="node-modules-eas-update-base-node${NODE_VERSION}-${OS_NAME}"
160-
161-
echo "🔍 Validating base branch artifact compatibility..."
162-
echo " Expected artifact: $EXPECTED_ARTIFACT"
163-
echo " Actual artifact: ${{ env.BASE_ARTIFACT_NAME }}"
164-
165-
if [ "$EXPECTED_ARTIFACT" != "${{ env.BASE_ARTIFACT_NAME }}" ]; then
166-
echo "::error title=Artifact Incompatibility::Node version or OS mismatch detected!"
167-
echo "❌ The node_modules artifact was built with different Node version or OS"
168-
echo " This could cause issues with native node modules"
169-
echo " Expected: $EXPECTED_ARTIFACT"
170-
echo " Actual: ${{ env.BASE_ARTIFACT_NAME }}"
171-
exit 1
172-
fi
173-
echo "✅ Base branch artifact compatibility validated"
137+
uses: ./.github/actions/validate-artifact-compatibility
138+
with:
139+
artifact-name: ${{ env.BASE_ARTIFACT_NAME }}
140+
artifact-prefix: node-modules-eas-update-base
141+
validation-context: base branch
174142

175143
- name: Download node_modules artifact (base branch)
176144
uses: actions/download-artifact@v4
@@ -179,14 +147,9 @@ jobs:
179147
path: main
180148

181149
- name: Restore executable permissions (base branch)
182-
working-directory: main
183-
run: |
184-
echo "🔧 Restoring executable permissions..."
185-
find node_modules/.bin -type f -exec chmod +x {} \; 2>/dev/null || true
186-
find node_modules -type f -name "*.node" -exec chmod +x {} \; 2>/dev/null || true
187-
find node_modules -path "*/bin/*" -type f -exec chmod +x {} \; 2>/dev/null || true
188-
find node_modules -path "*/sdks/*" -type f -exec chmod +x {} \; 2>/dev/null || true
189-
echo "✅ Permissions restored"
150+
uses: ./.github/actions/restore-node-modules-permissions
151+
with:
152+
working-directory: main
190153

191154
- name: Generate fingerprint (base branch)
192155
id: main_fingerprint
@@ -265,10 +228,10 @@ jobs:
265228
if: ${{ needs.fingerprint-comparison.outputs.fingerprints_equal == 'true' }}
266229
runs-on: ubuntu-latest
267230
steps:
268-
- name: Await approval from mobile platform team
231+
- name: Await approval from mobile release team
269232
uses: op5dev/require-team-approval@dfd7b8b9a88bf82a955c103f7e19642b0411aecd
270233
with:
271-
team: mobile-platform
234+
team: release-team
272235
pr-number: ${{ needs.validate-pr.outputs.pr_number }}
273236
token: ${{ secrets.METAMASK_MOBILE_ORG_READ_TOKEN }}
274237

@@ -345,38 +308,19 @@ jobs:
345308
node-version: '20'
346309

347310
- name: Validate artifact compatibility
348-
run: |
349-
NODE_VERSION=$(node --version | sed 's/v//')
350-
OS_NAME=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]')
351-
EXPECTED_ARTIFACT="node-modules-eas-update-pr-node${NODE_VERSION}-${OS_NAME}"
352-
353-
echo "🔍 Validating artifact compatibility..."
354-
echo " Expected artifact: $EXPECTED_ARTIFACT"
355-
echo " Actual artifact: ${{ env.ARTIFACT_NAME }}"
356-
357-
if [ "$EXPECTED_ARTIFACT" != "${{ env.ARTIFACT_NAME }}" ]; then
358-
echo "::error title=Artifact Incompatibility::Node version or OS mismatch detected!"
359-
echo "❌ The node_modules artifact was built with different Node version or OS"
360-
echo " This could cause issues with native node modules"
361-
echo " Expected: $EXPECTED_ARTIFACT"
362-
echo " Actual: ${{ env.ARTIFACT_NAME }}"
363-
exit 1
364-
fi
365-
echo "✅ Artifact compatibility validated"
311+
uses: ./.github/actions/validate-artifact-compatibility
312+
with:
313+
artifact-name: ${{ env.ARTIFACT_NAME }}
314+
artifact-prefix: node-modules-eas-update-pr
315+
validation-context: artifact
366316

367317
- name: Download node_modules artifact
368318
uses: actions/download-artifact@v4
369319
with:
370320
name: ${{ env.ARTIFACT_NAME }}
371321

372322
- name: Restore executable permissions
373-
run: |
374-
echo "🔧 Restoring executable permissions..."
375-
find node_modules/.bin -type f -exec chmod +x {} \; 2>/dev/null || true
376-
find node_modules -type f -name "*.node" -exec chmod +x {} \; 2>/dev/null || true
377-
find node_modules -path "*/bin/*" -type f -exec chmod +x {} \; 2>/dev/null || true
378-
find node_modules -path "*/sdks/*" -type f -exec chmod +x {} \; 2>/dev/null || true
379-
echo "✅ Permissions restored"
323+
uses: ./.github/actions/restore-node-modules-permissions
380324

381325
- name: Verify downloaded artifacts
382326
run: |

0 commit comments

Comments
 (0)