diff --git a/.github/workflow-scripts/actOnLabel.js b/.github/workflow-scripts/actOnLabel.js index 923e6baa44b..78571fd0ac0 100644 --- a/.github/workflow-scripts/actOnLabel.js +++ b/.github/workflow-scripts/actOnLabel.js @@ -7,7 +7,7 @@ * @format */ -module.exports = async (github, context, label) => { +module.exports = async (github, context, labelWithContext) => { const closeIssue = async () => { await github.rest.issues.update({ issue_number: context.issue.number, @@ -45,7 +45,7 @@ module.exports = async (github, context, label) => { }); }; - switch (label) { + switch (labelWithContext.label) { case 'Type: Invalid': await addComment( `| :warning: | Issue is Invalid |\n` + @@ -102,11 +102,11 @@ module.exports = async (github, context, label) => { ); await requestAuthorFeedback(); return; - case 'Needs: Verify on Latest Version': + case 'Newer Patch Available': await addComment( `| :warning: | Newer Version of React Native is Available! |\n` + `| --- | --- |\n` + - `| :information_source: | You are on a supported minor version, but it looks like there's a newer patch available. Please [upgrade](https://reactnative.dev/docs/upgrading) to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |`, + `| :information_source: | You are on a supported minor version, but it looks like there's a newer patch available - ${labelWithContext.newestPatch}. Please [upgrade](https://reactnative.dev/docs/upgrading) to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases. |`, ); return; case 'Needs: Version Info': diff --git a/.github/workflows/addDescriptiveLabels.js b/.github/workflow-scripts/addDescriptiveLabels.js similarity index 100% rename from .github/workflows/addDescriptiveLabels.js rename to .github/workflow-scripts/addDescriptiveLabels.js diff --git a/.github/workflow-scripts/verifyVersion.js b/.github/workflow-scripts/verifyVersion.js index da66a1f2f0f..b91efe898ee 100644 --- a/.github/workflow-scripts/verifyVersion.js +++ b/.github/workflow-scripts/verifyVersion.js @@ -23,7 +23,7 @@ module.exports = async (github, context) => { if (reportedVersionIsNightly(issueVersionUnparsed, issueVersion)) return; if (!issueVersion) { - return 'Needs: Version Info'; + return {label: 'Needs: Version Info'}; } // Ensure the version matches one we support @@ -43,7 +43,7 @@ module.exports = async (github, context) => { const latestVersion = parseVersionFromString(latestRelease.name); if (!isVersionSupported(issueVersion, latestVersion)) { - return 'Type: Unsupported Version'; + return {label: 'Type: Unsupported Version'}; } // We want to encourage users to repro the issue on the highest available patch for the given minor. @@ -52,7 +52,10 @@ module.exports = async (github, context) => { recentReleases, ); if (latestPatchForVersion > issueVersion.patch) { - return 'Needs: Verify on Latest Version'; + return { + label: 'Newer Patch Available', + newestPatch: `${issueVersion.major}.${issueVersion.minor}.${latestPatchForVersion}`, + }; } }; diff --git a/.github/workflows/on-issue-labeled.yml b/.github/workflows/on-issue-labeled.yml index f4e976bd3d9..14f9d4e9c5d 100644 --- a/.github/workflows/on-issue-labeled.yml +++ b/.github/workflows/on-issue-labeled.yml @@ -23,25 +23,25 @@ jobs: with: script: | const verifyVersion = require('./.github/workflow-scripts/verifyVersion.js') - const labelToAdd = await verifyVersion(github, context); + const labelWithContext = await verifyVersion(github, context); - if(labelToAdd) { + if(labelWithContext && labelWithContext.label) { await github.rest.issues.addLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - labels: [labelToAdd] + labels: [labelWithContext.label] }) const actOnLabel = require('./.github/workflow-scripts/actOnLabel.js') - await actOnLabel(github, context, labelToAdd) + await actOnLabel(github, context, labelWithContext) } - name: Add descriptive label uses: actions/github-script@v6 with: script: | - const addDescriptiveLabel = require('./.github/workflows/addDescriptiveLabels.js') + const addDescriptiveLabel = require('./.github/workflow-scripts/addDescriptiveLabels.js') await addDescriptiveLabel(github, context); # Reacts to the label that triggered this workflow (added manually or via other workflows) @@ -54,4 +54,4 @@ jobs: with: script: | const actOnLabel = require('./.github/workflow-scripts/actOnLabel.js') - await actOnLabel(github, context, context.payload.label.name) + await actOnLabel(github, context, {label: context.payload.label.name})