in src/main/scala/com/gu/iosdeployments/Lambda.scala [102:127]
def process(env: Env): Unit = {
logger.info("Loading configuration...")
val appStoreConnectConfig = AppStoreConnectConfig(env)
val appStoreConnectToken = JwtTokenBuilder.buildToken(appStoreConnectConfig)
val gitHubConfig = GitHubConfig(env)
logger.info("Successfully loaded configuration...")
val result = for {
runningDeployments <- GitHubApi.getRunningDeployments(gitHubConfig)
appStoreConnectBetaBuilds <- AppStoreConnectApi.getLatestBetaBuilds(appStoreConnectToken, appStoreConnectConfig)
appStoreConnectProductionBuild <- AppStoreConnectApi.getLatestProductionBuilds(appStoreConnectToken, appStoreConnectConfig)
maybeBetaDeployment = runningDeployments.find(_.environment.contains("beta"))
maybeProductionDeployment = runningDeployments.find(_.environment == "production")
handleBeta <- handleBetaDeployment(env, maybeBetaDeployment, appStoreConnectBetaBuilds, appStoreConnectToken, gitHubConfig)
handleProduction <- handleProductionDeployment(maybeProductionDeployment, appStoreConnectProductionBuild, gitHubConfig)
} yield {
handleProduction
}
result match {
case Success(_) => logger.info("Successfully checked deployment status")
case Failure(exception) =>
logger.error(s"Failed to check deployment status due to: ${exception}", exception)
throw exception
}
}