Repository navigation
[No QA]Update to deploy HybridApp production iOS and Android using slow rollouts #52283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dfbd12a
Add new cron Android bump to update Android production version
AndrewGable 27bd813
Build actions
AndrewGable f7d951f
Tweak inputs
AndrewGable 814a5d0
Rebuild actions
AndrewGable df349de
Add GITHUB_TOKEN
AndrewGable 5a7f062
Update rollout percentage to be a decimal number
AndrewGable 379c3ac
Fix prettier
AndrewGable b1b7d75
Fix lint
AndrewGable 0f2272e
re-build github actions code
AndrewGable 53416c8
Update to deploy HybridApp to production
AndrewGable f9ed151
Add iOS rollout completion logic
AndrewGable 9ac400f
Write some more logic to update Android rollouts
AndrewGable abee1f0
Merge branch 'main' into andrew-android-bump
AndrewGable e1315f2
Remove testing and add ruby setup
AndrewGable 40c5cce
Update peer review comments
AndrewGable a7316b8
Update compiled code
AndrewGable ed67b01
Apply suggestions from code review
AndrewGable 88301f9
Update .github/workflows/androidBump.yml
AndrewGable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5,684 changes: 2,842 additions & 2,842 deletions
5,684
.github/actions/javascript/authorChecklist/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
5,114 changes: 2,557 additions & 2,557 deletions
5,114
.github/actions/javascript/awaitStagingDeploys/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: 'Check Android Status' | ||
| description: 'Checks the status of the Android track and calculates the rollout percentage.' | ||
| inputs: | ||
| GITHUB_TOKEN: | ||
| description: Auth token for New Expensify Github | ||
| required: true | ||
| GOOGLE_KEY_FILE: | ||
| description: Authentication file for Google Cloud API | ||
| required: true | ||
| PACKAGE_NAME: | ||
| description: Package name to check the status of | ||
| required: true | ||
| outputs: | ||
| HALTED: | ||
| description: True if the app is halted, false otherwise | ||
| ROLLOUT_PERCENTAGE: | ||
| description: The calculated rollout percentage | ||
| runs: | ||
| using: 'node20' | ||
| main: './index.js' |
99 changes: 99 additions & 0 deletions
99
.github/actions/javascript/checkAndroidStatus/checkAndroidStatus.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import * as core from '@actions/core'; | ||
| import {google} from 'googleapis'; | ||
| import CONST from '@github/libs/CONST'; | ||
| import GithubUtils from '@github/libs/GithubUtils'; | ||
|
|
||
| const PACKAGE_NAME = core.getInput('PACKAGE_NAME', {required: true}); | ||
| const GOOGLE_KEY_FILE = core.getInput('GOOGLE_KEY_FILE', {required: true}); | ||
| const HALTED_STATUS = 'halted'; | ||
|
|
||
| async function checkAndroidStatus() { | ||
| const auth = new google.auth.GoogleAuth({ | ||
| keyFile: GOOGLE_KEY_FILE, | ||
| scopes: ['https://www.googleapis.com/auth/androidpublisher'], | ||
| }); | ||
|
|
||
| const androidApi = google.androidpublisher({ | ||
| version: 'v3', | ||
| auth, | ||
| }); | ||
|
|
||
| try { | ||
| // The Google Play API requires an edit ID to make changes to the app | ||
| const editResponse = await androidApi.edits.insert({ | ||
| packageName: PACKAGE_NAME, | ||
| }); | ||
| const editId = editResponse.data.id ?? 'undefined'; | ||
|
|
||
| // Get the production track status | ||
| const trackResponse = await androidApi.edits.tracks.get({ | ||
| packageName: PACKAGE_NAME, | ||
| editId, | ||
| track: 'production', | ||
| }); | ||
|
|
||
| const status = trackResponse.data.releases?.[0]?.status ?? 'undefined'; | ||
| console.log('Track status:', status); | ||
|
|
||
| // Check if the status is halted | ||
| const HALTED = status === HALTED_STATUS; | ||
| core.setOutput('HALTED', HALTED); | ||
| } catch (error) { | ||
| console.error('Error checking track status:', error); | ||
| process.exit(1); | ||
| } | ||
| } | ||
|
|
||
| async function getLatestReleaseDate() { | ||
| const {data} = await GithubUtils.octokit.repos.getLatestRelease({ | ||
| owner: CONST.GITHUB_OWNER, | ||
| repo: CONST.APP_REPO, | ||
| }); | ||
|
|
||
| const releaseDate = data.published_at?.split('T')[0]; | ||
|
AndrewGable marked this conversation as resolved.
Resolved
|
||
| if (!releaseDate) { | ||
| throw new Error('Unable to retrieve the latest release date from GitHub'); | ||
| } | ||
|
|
||
| console.log('Latest release date:', releaseDate); | ||
| return releaseDate; | ||
| } | ||
|
|
||
| function calculateRolloutPercentage(releaseDate: string): number { | ||
| const release = new Date(releaseDate); | ||
| const current = new Date(); | ||
| const daysSinceRelease = Math.floor((current.getTime() - release.getTime()) / (1000 * 60 * 60 * 24)); | ||
| console.log('Days since release:', daysSinceRelease); | ||
|
|
||
| if (daysSinceRelease === 1) { | ||
| return 0.01; | ||
| } | ||
| if (daysSinceRelease === 2) { | ||
| return 0.02; | ||
| } | ||
| if (daysSinceRelease === 3) { | ||
| return 0.05; | ||
| } | ||
| if (daysSinceRelease === 4) { | ||
| return 0.1; | ||
| } | ||
| if (daysSinceRelease === 5) { | ||
| return 0.2; | ||
| } | ||
| if (daysSinceRelease === 6) { | ||
| return 0.5; | ||
| } | ||
| if (daysSinceRelease === 7) { | ||
| return 1; | ||
| } | ||
| // If we did not get a valid number of days since release (1-7), return -1 | ||
| return -1; | ||
| } | ||
|
|
||
| checkAndroidStatus() | ||
| .then(getLatestReleaseDate) | ||
| .then((releaseDate) => { | ||
| const rolloutPercentage = calculateRolloutPercentage(releaseDate); | ||
| console.log('Rollout percentage:', rolloutPercentage); | ||
| core.setOutput('ROLLOUT_PERCENTAGE', rolloutPercentage); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.