in src/main/scala/com/gu/iosdeployments/Lambda.scala [26:64]
def handleBetaDeployment(env: Env, maybeDeployment: Option[RunningLiveAppDeployment], latestBetas: List[LiveAppBeta], appStoreConnectToken: String, gitHubConfig: GitHubConfig): Try[Unit] = {
val externalTesterConfig = if (env.stage == "PROD") {
Config.externalTesterConfigForProd
} else {
Config.externalTesterConfigForTesting
}
maybeDeployment match {
case Some(runningDeployment) =>
val attemptToFindBeta = latestBetas.find(_.version == runningDeployment.version)
(runningDeployment.environment, attemptToFindBeta) match {
case ("internal-beta", Some(LiveAppBeta(_, _, _, "IN_BETA_TESTING", _))) =>
logger.info(s"Internal beta deployment for ${runningDeployment.version} is complete...")
GitHubApi.markDeploymentAsSuccess(gitHubConfig, runningDeployment)
case ("external-beta", Some(LiveAppBeta(_, _, _, _, "IN_BETA_TESTING"))) =>
logger.info(s"External beta deployment for ${runningDeployment.version} is complete...")
GitHubApi.markDeploymentAsSuccess(gitHubConfig, runningDeployment)
case ("external-beta", Some(build @ LiveAppBeta(_, _, _, "IN_BETA_TESTING", "READY_FOR_BETA_SUBMISSION"))) =>
logger.info(s"External beta deployment for ${runningDeployment.version} can now be submitted for review...")
AppStoreConnectApi.submitForBetaTesting(appStoreConnectToken, build.buildId)
case ("external-beta", Some(build @ LiveAppBeta(_, _, _, _, "BETA_APPROVED"))) =>
logger.info(s"External beta deployment for ${runningDeployment.version} can now be distributed to users...")
AppStoreConnectApi.distributeToExternalTesters(appStoreConnectToken, build.buildId, externalTesterConfig)
case ("external-beta", Some(build @ LiveAppBeta(_, _, _, _, "BETA_REJECTED"))) =>
logger.info(s"External beta for ${runningDeployment.version} was rejected.")
GitHubApi.markDeploymentAsFailure(gitHubConfig, runningDeployment)
case (_, Some(LiveAppBeta(_, _, _, "EXPIRED", "EXPIRED"))) =>
logger.info(s"Beta deployment for ${runningDeployment.version} was (presumably) successful, but beta build was expired before deployment completed...")
GitHubApi.markDeploymentAsSuccess(gitHubConfig, runningDeployment)
case (_, None) =>
notPresentInAppStoreConnect(runningDeployment, gitHubConfig)
case _ =>
Try(logger.info(s"No action was required for beta deployment ${runningDeployment.version}. Full details are: $attemptToFindBeta"))
}
case None =>
Try(logger.info("No running beta deployments found."))
}
}