Skip to content

Commit f06f545

Browse files
committed
fix: install properly packages and pass environment variables
1 parent ae76548 commit f06f545

8 files changed

Lines changed: 91 additions & 42 deletions

File tree

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: 'Find Artifact'
2-
description: 'Find the latest artifact'
1+
name: "Find Artifact"
2+
description: "Find the latest artifact"
33
inputs:
44
name:
5-
description: 'Artifact name'
5+
description: "Artifact name"
66
required: false
77
re-sign:
88
description: Re-sign the app bundle with new JS bundle
@@ -19,17 +19,27 @@ inputs:
1919
default: ${{ github.repository }}
2020
outputs:
2121
artifact-id:
22-
description: 'The ID of the artifact'
22+
description: "The ID of the artifact"
23+
value: ${{ steps.find-artifact.outputs.artifact-id }}
2324
artifact-url:
24-
description: 'The URL of the artifact'
25+
description: "The URL of the artifact"
26+
value: ${{ steps.find-artifact.outputs.artifact-url }}
2527
artifact-ids:
26-
description: 'All IDs of the artifacts matching the name'
28+
description: "All IDs of the artifacts matching the name"
29+
value: ${{ steps.find-artifact.outputs.artifact-ids }}
2730
runs:
28-
using: 'composite'
31+
using: "composite"
2932
steps:
3033
- name: Install dependencies
3134
run: npm install
3235
shell: bash
33-
- name: Run find artifact
34-
run: node index.js
36+
working-directory: ${{ github.action_path }}
37+
- name: Find artifact
38+
id: find-artifact
39+
env:
40+
INPUT_NAME: ${{ inputs.name }}
41+
INPUT_RE_SIGN: ${{ inputs.re-sign }}
42+
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
43+
INPUT_REPOSITORY: ${{ inputs.repository }}
44+
run: node ${{ github.action_path }}/index.mjs
3545
shell: bash
Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const core = require('@actions/core');
2-
const github = require('@actions/github');
1+
import * as core from "@actions/core";
2+
import * as github from "@actions/github";
33

44
const perPage = 100; // Maximum allowed by GitHub API
55

@@ -9,8 +9,8 @@ async function fetchArtifacts(octokit, repository, name) {
99

1010
while (true) {
1111
const response = await octokit.rest.actions.listArtifactsForRepo({
12-
owner: repository.split('/')[0],
13-
repo: repository.split('/')[1],
12+
owner: repository.split("/")[0],
13+
repo: repository.split("/")[1],
1414
name,
1515
per_page: perPage,
1616
page,
@@ -31,18 +31,31 @@ async function fetchArtifacts(octokit, repository, name) {
3131
}
3232

3333
function getPrNumber() {
34-
if (github.context.eventName === 'pull_request') {
34+
if (github.context.eventName === "pull_request") {
3535
return github.context.payload.pull_request.number;
3636
}
3737
return undefined;
3838
}
3939

4040
async function run() {
4141
try {
42-
const token = core.getInput('github-token');
43-
const repository = core.getInput('repository');
44-
const name = core.getInput('name');
45-
const reSign = core.getInput('re-sign');
42+
const token = core.getInput("github_token") || process.env.GITHUB_TOKEN;
43+
44+
if (!token) {
45+
throw new Error("GitHub token is required");
46+
}
47+
48+
const repository = core.getInput("repository");
49+
if (!repository) {
50+
throw new Error("Repository is required");
51+
}
52+
53+
const name = core.getInput("name");
54+
if (!name) {
55+
throw new Error("Artifact name is required");
56+
}
57+
58+
const reSign = core.getInput("re_sign");
4659
const prNumber = getPrNumber();
4760

4861
const octokit = github.getOctokit(token);
@@ -61,20 +74,20 @@ async function run() {
6174
for (const artifact of artifacts) {
6275
console.log(
6376
`- ID: ${artifact.id}, Name: ${artifact.name}, Size: ${formatSize(
64-
artifact.size_in_bytes,
65-
)}, Expires at: ${artifact.expires_at}`,
77+
artifact.size_in_bytes
78+
)}, Expires at: ${artifact.expires_at}`
6679
);
6780
}
6881

69-
const firstArtifact = artifacts.find(artifact => !artifact.expired);
82+
const firstArtifact = artifacts.find((artifact) => !artifact.expired);
7083
console.log(`First artifact: ${JSON.stringify(firstArtifact, null, 2)}`);
7184

7285
const url = formatDownloadUrl(
7386
repository,
7487
firstArtifact.workflow_run.id,
75-
firstArtifact.id,
88+
firstArtifact.id
7689
);
77-
console.log('Stable download URL:', url);
90+
console.log("Stable download URL:", url);
7891

7992
let artifactName = name;
8093
// There are artifacts from PR but the base artifact is gone, recreate with the original name
@@ -84,12 +97,12 @@ async function run() {
8497
} else if (prNumber && reSign) {
8598
artifactName = `${name}-${prNumber}`;
8699
}
87-
core.setOutput('artifact-name', artifactName);
88-
core.setOutput('artifact-id', firstArtifact.id);
89-
core.setOutput('artifact-url', url);
100+
core.setOutput("artifact-name", artifactName);
101+
core.setOutput("artifact-id", firstArtifact.id);
102+
core.setOutput("artifact-url", url);
90103
core.setOutput(
91-
'artifact-ids',
92-
artifactsByPrNumber.map(artifact => artifact.id).join(' '),
104+
"artifact-ids",
105+
artifactsByPrNumber.map((artifact) => artifact.id).join(" ")
93106
);
94107
} catch (error) {
95108
core.setFailed(`Action failed with error: ${error.message}`);

.github/actions/rnef-native-fingerprint/action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ inputs:
1111
outputs:
1212
hash:
1313
description: 'The fingerprint hash'
14+
value: ${{ steps.fingerprint.outputs.hash }}
1415
runs:
15-
using: 'composite'
16+
using: "composite"
1617
steps:
1718
- name: Install dependencies
1819
run: npm install
1920
shell: bash
21+
working-directory: ${{ github.action_path }}
2022
- name: Run fingerprint
21-
run: node index.mjs
23+
id: fingerprint
24+
env:
25+
INPUT_PLATFORM: ${{ inputs.platform }}
26+
INPUT_WORKING_DIRECTORY: ${{ inputs.working-directory }}
27+
run: node ${{ github.action_path }}/index.mjs
2228
shell: bash

.github/actions/rnef-native-fingerprint/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Generate native fingerprint for RNEF builds",
55
"main": "index.mjs",
66
"dependencies": {
7+
"@rnef/config": "^0.4.1",
78
"@actions/core": "^1.11.1"
89
}
910
}

.github/actions/rnef-post-build/action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ inputs:
1313
required: false
1414
default: ${{ github.token }}
1515
runs:
16-
using: 'composite'
16+
using: "composite"
1717
steps:
1818
- name: Install dependencies
1919
run: npm install
2020
shell: bash
21-
- name: Run post build
22-
run: node index.js
21+
working-directory: ${{ github.action_path }}
22+
- name: Post build
23+
id: post-build
24+
env:
25+
INPUT_ARTIFACT_URL: ${{ inputs.artifact-url }}
26+
INPUT_TITLE: ${{ inputs.title }}
27+
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
28+
run: node ${{ github.action_path }}/index.mjs
2329
shell: bash
Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1-
const core = require('@actions/core');
2-
const github = require('@actions/github');
1+
import * as core from '@actions/core';
2+
import * as github from '@actions/github';
33

44
async function run() {
5-
const token = core.getInput('github-token');
6-
const titleInput = core.getInput('title');
7-
const artifactUrl = core.getInput('artifact-url');
5+
const token = core.getInput("github_token") || process.env.GITHUB_TOKEN;
6+
if (!token) {
7+
throw new Error("GitHub token is required");
8+
}
9+
10+
const titleInput = core.getInput("title");
11+
if (!titleInput) {
12+
throw new Error("Title is required");
13+
}
14+
15+
const artifactUrl = core.getInput("artifact_url");
16+
if (!artifactUrl) {
17+
throw new Error("Artifact URL is required");
18+
}
819

920
const title = `## ${titleInput}`;
1021
const body = `🔗 [Download link](${artifactUrl}).\n\n

action.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ runs:
102102

103103
- name: Native Fingerprint
104104
id: fingerprint
105-
uses: callstackincubator/ios/.github/actions/rnef-native-fingerprint@v1
105+
uses: callstackincubator/ios/.github/actions/rnef-native-fingerprint@fix/composite
106106
with:
107107
platform: ios
108108
working-directory: ${{ inputs.working-directory }}
@@ -114,10 +114,11 @@ runs:
114114

115115
- name: Find artifact URL
116116
id: find-artifact
117-
uses: callstackincubator/ios/.github/actions/find-artifact@v1
117+
uses: callstackincubator/ios/.github/actions/find-artifact@fix/composite
118118
with:
119119
name: ${{ env.ARTIFACT_NAME }}
120120
re-sign: ${{ inputs.re-sign }}
121+
github-token: ${{ inputs.github-token }}
121122

122123
- name: Set Provisioning Profile Path
123124
run: |
@@ -256,7 +257,8 @@ runs:
256257

257258
- name: Post Build
258259
if: ${{ github.event_name == 'pull_request' && inputs.comment-bot == 'true' }}
259-
uses: callstackincubator/ios/.github/actions/rnef-post-build@v1
260+
uses: callstackincubator/ios/.github/actions/rnef-post-build@fix/composite
260261
with:
261262
title: iOS ${{ inputs.configuration }} ${{ inputs.destination == 'simulator' && 'APP for simulators' || 'IPA for physical devices' }}
262263
artifact-url: ${{ steps.upload-artifact.outputs.artifact-url || steps.find-artifact.outputs.artifact-url }}
264+
github-token: ${{ inputs.github-token }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "action-ios",
33
"version": "1.0.0",
4-
"description": "GitHub Action for building iOS applications using RNEF (React Native EAS Fastlane)",
4+
"description": "GitHub Action for building iOS applications using RNEF (React Native Enterprise Framework)",
55
"main": "index.js",
66
"author": "",
77
"license": "MIT",

0 commit comments

Comments
 (0)