Skip to content
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

[No QA]Update to deploy HybridApp production iOS and Android using slow rollouts #52283

Merged
merged 18 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,684 changes: 2,842 additions & 2,842 deletions .github/actions/javascript/authorChecklist/index.js

Large diffs are not rendered by default.

5,114 changes: 2,557 additions & 2,557 deletions .github/actions/javascript/awaitStagingDeploys/index.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions .github/actions/javascript/checkAndroidStatus/action.yml
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'
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);
AndrewGable marked this conversation as resolved.
Show resolved Hide resolved
} 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.
Show resolved Hide 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);
});
Loading
Loading