Skip to content

Commit 32a0cf3

Browse files
authored
Merge pull request Expensify#68478 from Expensify/jules-commentOnDeployedMobileExpensifyIssues
[NO QA] Fix issue preventing deployed version comments to Mobile-Expensify PRs
2 parents 130fcfa + dcd0deb commit 32a0cf3

8 files changed

Lines changed: 36 additions & 16 deletions

File tree

.github/actions/javascript/createOrUpdateStagingDeploy/createOrUpdateStagingDeploy.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,12 @@ async function run(): Promise<IssuesCreateResponse | void> {
9292
}
9393
} catch (error) {
9494
// Check if this is a forked repository
95-
if (process.env.GITHUB_REPOSITORY !== CONST.APP_REPO) {
95+
if (process.env.GITHUB_REPOSITORY !== `${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`) {
9696
console.warn(
9797
"⚠️ Unable to fetch Mobile-Expensify PRs because this workflow is running on a forked repository and secrets aren't accessble. This is expected for development/testing on forks.",
9898
);
9999
} else {
100-
console.error('Failed to fetch Mobile-Expensify PRs from main repository:', error);
101-
throw error;
100+
console.error('Failed to fetch Mobile-Expensify PRs:', error);
102101
}
103102
}
104103

.github/actions/javascript/createOrUpdateStagingDeploy/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11602,12 +11602,11 @@ async function run() {
1160211602
}
1160311603
catch (error) {
1160411604
// Check if this is a forked repository
11605-
if (process.env.GITHUB_REPOSITORY !== CONST_1.default.APP_REPO) {
11605+
if (process.env.GITHUB_REPOSITORY !== `${CONST_1.default.GITHUB_OWNER}/${CONST_1.default.APP_REPO}`) {
1160611606
console.warn("⚠️ Unable to fetch Mobile-Expensify PRs because this workflow is running on a forked repository and secrets aren't accessble. This is expected for development/testing on forks.");
1160711607
}
1160811608
else {
11609-
console.error('Failed to fetch Mobile-Expensify PRs from main repository:', error);
11610-
throw error;
11609+
console.error('Failed to fetch Mobile-Expensify PRs:', error);
1161111610
}
1161211611
}
1161311612
// Next, we generate the checklist body

.github/actions/javascript/getDeployPullRequestList/getDeployPullRequestList.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async function run() {
7272
console.log('Found Mobile-Expensify pull request list: ', mobileExpensifyPRList);
7373
} catch (error) {
7474
// Check if this is a forked repository
75-
if (process.env.GITHUB_REPOSITORY !== CONST.APP_REPO) {
75+
if (process.env.GITHUB_REPOSITORY !== `${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`) {
7676
console.warn(
7777
"⚠️ Unable to fetch Mobile-Expensify PRs because this workflow is running on a forked repository and secrets aren't accessible. This is expected for development/testing on forks.",
7878
);

.github/actions/javascript/getDeployPullRequestList/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11630,7 +11630,7 @@ async function run() {
1163011630
}
1163111631
catch (error) {
1163211632
// Check if this is a forked repository
11633-
if (process.env.GITHUB_REPOSITORY !== CONST_1.default.APP_REPO) {
11633+
if (process.env.GITHUB_REPOSITORY !== `${CONST_1.default.GITHUB_OWNER}/${CONST_1.default.APP_REPO}`) {
1163411634
console.warn("⚠️ Unable to fetch Mobile-Expensify PRs because this workflow is running on a forked repository and secrets aren't accessible. This is expected for development/testing on forks.");
1163511635
}
1163611636
else {

.github/actions/javascript/markPullRequestsAsDeployed/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12814,7 +12814,7 @@ async function commentStagingDeployPRs(prList, repoName, recentTags, getDeployMe
1281412814
if (error.status === 404) {
1281512815
console.log(`Unable to comment on ${repoName} PR #${prNumber}. GitHub responded with 404.`);
1281612816
}
12817-
else if (repoName === CONST_1.default.MOBILE_EXPENSIFY_REPO && process.env.GITHUB_REPOSITORY !== CONST_1.default.APP_REPO) {
12817+
else if (repoName === CONST_1.default.MOBILE_EXPENSIFY_REPO && process.env.GITHUB_REPOSITORY !== `${CONST_1.default.GITHUB_OWNER}/${CONST_1.default.APP_REPO}`) {
1281812818
console.warn(`Unable to comment on ${repoName} PR #${prNumber} from forked repository. This is expected.`);
1281912819
}
1282012820
else {
@@ -12874,10 +12874,14 @@ async function run() {
1287412874
for (const pr of prList) {
1287512875
await commentPR(pr, deployMessage);
1287612876
}
12877+
console.log(`✅ Added production deploy comment on ${prList.length} App PRs`);
1287712878
// Comment on Mobile-Expensify PRs as well
1287812879
for (const pr of mobileExpensifyPRList) {
1287912880
await commentPR(pr, deployMessage, CONST_1.default.MOBILE_EXPENSIFY_REPO);
1288012881
}
12882+
if (mobileExpensifyPRList.length > 0) {
12883+
console.log(`✅ Added production deploy comment on ${mobileExpensifyPRList.length} Mobile-Expensify PRs`);
12884+
}
1288112885
return;
1288212886
}
1288312887
const { data: appRecentTags } = await GithubUtils_1.default.octokit.repos.listTags({
@@ -12897,7 +12901,7 @@ async function run() {
1289712901
mobileExpensifyRecentTags = response.data;
1289812902
}
1289912903
catch (error) {
12900-
if (process.env.GITHUB_REPOSITORY !== CONST_1.default.APP_REPO) {
12904+
if (process.env.GITHUB_REPOSITORY !== `${CONST_1.default.GITHUB_OWNER}/${CONST_1.default.APP_REPO}`) {
1290112905
console.warn('Unable to fetch Mobile-Expensify tags from forked repository. This is expected.');
1290212906
}
1290312907
else {
@@ -12907,7 +12911,11 @@ async function run() {
1290712911
}
1290812912
// Comment on the PRs
1290912913
await commentStagingDeployPRs(prList, CONST_1.default.APP_REPO, appRecentTags, getDeployMessage);
12910-
await commentStagingDeployPRs(mobileExpensifyPRList, CONST_1.default.MOBILE_EXPENSIFY_REPO, mobileExpensifyRecentTags, getDeployMessage);
12914+
console.log(`✅ Added staging deploy comment ${prList.length} App PRs`);
12915+
if (mobileExpensifyPRList.length > 0) {
12916+
await commentStagingDeployPRs(mobileExpensifyPRList, CONST_1.default.MOBILE_EXPENSIFY_REPO, mobileExpensifyRecentTags, getDeployMessage);
12917+
console.log(`✅ Completed staging deploy comment on ${mobileExpensifyPRList.length} Mobile-Expensify PRs`);
12918+
}
1291112919
}
1291212920
if (require.main === require.cache[eval('__filename')]) {
1291312921
run();

.github/actions/javascript/markPullRequestsAsDeployed/markPullRequestsAsDeployed.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async function commentStagingDeployPRs(
8686
} catch (error) {
8787
if ((error as RequestError).status === 404) {
8888
console.log(`Unable to comment on ${repoName} PR #${prNumber}. GitHub responded with 404.`);
89-
} else if (repoName === CONST.MOBILE_EXPENSIFY_REPO && process.env.GITHUB_REPOSITORY !== CONST.APP_REPO) {
89+
} else if (repoName === CONST.MOBILE_EXPENSIFY_REPO && process.env.GITHUB_REPOSITORY !== `${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`) {
9090
console.warn(`Unable to comment on ${repoName} PR #${prNumber} from forked repository. This is expected.`);
9191
} else {
9292
throw error;
@@ -155,11 +155,15 @@ async function run() {
155155
for (const pr of prList) {
156156
await commentPR(pr, deployMessage);
157157
}
158+
console.log(`✅ Added production deploy comment on ${prList.length} App PRs`);
158159

159160
// Comment on Mobile-Expensify PRs as well
160161
for (const pr of mobileExpensifyPRList) {
161162
await commentPR(pr, deployMessage, CONST.MOBILE_EXPENSIFY_REPO);
162163
}
164+
if (mobileExpensifyPRList.length > 0) {
165+
console.log(`✅ Added production deploy comment on ${mobileExpensifyPRList.length} Mobile-Expensify PRs`);
166+
}
163167
return;
164168
}
165169

@@ -180,7 +184,7 @@ async function run() {
180184
});
181185
mobileExpensifyRecentTags = response.data;
182186
} catch (error) {
183-
if (process.env.GITHUB_REPOSITORY !== CONST.APP_REPO) {
187+
if (process.env.GITHUB_REPOSITORY !== `${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`) {
184188
console.warn('Unable to fetch Mobile-Expensify tags from forked repository. This is expected.');
185189
} else {
186190
console.error('Failed to fetch Mobile-Expensify tags:', error);
@@ -190,7 +194,12 @@ async function run() {
190194

191195
// Comment on the PRs
192196
await commentStagingDeployPRs(prList, CONST.APP_REPO, appRecentTags, getDeployMessage);
193-
await commentStagingDeployPRs(mobileExpensifyPRList, CONST.MOBILE_EXPENSIFY_REPO, mobileExpensifyRecentTags, getDeployMessage);
197+
console.log(`✅ Added staging deploy comment ${prList.length} App PRs`);
198+
199+
if (mobileExpensifyPRList.length > 0) {
200+
await commentStagingDeployPRs(mobileExpensifyPRList, CONST.MOBILE_EXPENSIFY_REPO, mobileExpensifyRecentTags, getDeployMessage);
201+
console.log(`✅ Completed staging deploy comment on ${mobileExpensifyPRList.length} Mobile-Expensify PRs`);
202+
}
194203
}
195204

196205
if (require.main === module) {

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ jobs:
818818
uses: ./.github/workflows/postDeployComments.yml
819819
if: ${{ always() && fromJSON(needs.checkDeploymentSuccess.outputs.IS_AT_LEAST_ONE_PLATFORM_DEPLOYED) }}
820820
needs: [prep, android, desktop, ios, web, checkDeploymentSuccess, createRelease]
821+
secrets: inherit
821822
with:
822823
version: ${{ needs.prep.outputs.APP_VERSION }}
823824
env: ${{ github.ref == 'refs/heads/production' && 'production' || 'staging' }}

.github/workflows/postDeployComments.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ on:
2727
description: Desktop deploy status
2828
required: true
2929
type: string
30+
secrets:
31+
OS_BOTIFY_TOKEN:
32+
description: Token for accessing Mobile-Expensify repository
33+
required: true
3034
workflow_dispatch:
3135
inputs:
3236
version:
@@ -102,7 +106,7 @@ jobs:
102106
with:
103107
# Staging tags use the `-staging` suffix, production tags use the version only
104108
TAG: ${{ inputs.version }}${{ inputs.env == 'staging' && '-staging' || '' }}
105-
GITHUB_TOKEN: ${{ github.token }}
109+
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
106110
IS_PRODUCTION_DEPLOY: ${{ inputs.env == 'production' }}
107111

108112
- name: Comment on issues
@@ -112,7 +116,7 @@ jobs:
112116
MOBILE_EXPENSIFY_PR_LIST: ${{ steps.getPullRequestList.outputs.MOBILE_EXPENSIFY_PR_LIST }}
113117
IS_PRODUCTION_DEPLOY: ${{ inputs.env == 'production' }}
114118
DEPLOY_VERSION: ${{ inputs.version }}
115-
GITHUB_TOKEN: ${{ github.token }}
119+
GITHUB_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
116120
ANDROID: ${{ inputs.android }}
117121
DESKTOP: ${{ inputs.desktop }}
118122
IOS: ${{ inputs.ios }}

0 commit comments

Comments
 (0)