How to use the @actions/core.error function in @actions/core

To help you get started, we’ve selected a few @actions/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / webapps-deploy / src / main.ts View on Github external
// get app kind
    if(!!taskParams.endpoint) {
      await taskParams.getResourceDetails();
      type = DEPLOYMENT_PROVIDER_TYPES.SPN;
    }
    var deploymentProvider = new WebAppDeploymentProvider(type);

    core.debug("Predeployment Step Started");
    await deploymentProvider.PreDeploymentStep();

    core.debug("Deployment Step Started");
    await deploymentProvider.DeployWebAppStep();
  }
  catch(error) {
    isDeploymentSuccess = false;
    core.error("Deployment Failed with Error: " + error);
    core.setFailed(error);
  }
  finally {
      if(deploymentProvider != null) {
          await deploymentProvider.UpdateDeploymentStatus(isDeploymentSuccess);
      }
      
      // Reset AZURE_HTTP_USER_AGENT
      core.exportVariable('AZURE_HTTP_USER_AGENT', prefix);
      core.debug(isDeploymentSuccess ? "Deployment Succeeded" : "Deployment failed");
  }
}
github Azure / k8s-deploy / src / utilities / manifest-stability-utility.ts View on Github external
}
    podStatus = getPodStatus(kubectl, podName);
    switch (podStatus.phase) {
        case 'Succeeded':
        case 'Running':
            if (isPodReady(podStatus)) {
                console.log(`pod/${podName} is successfully rolled out`);
            }
            break;
        case 'Pending':
            if (!isPodReady(podStatus)) {
                core.warning(`pod/${podName} rollout status check timedout`);
            }
            break;
        case 'Failed':
            core.error(`pod/${podName} rollout failed`);
            break;
        default:
            core.warning(`pod/${podName} rollout status: ${podStatus.phase}`);
    }
}
github maierj / fastlane-action / main.js View on Github external
function setFailed(error) {
    core.error(error);
    core.setFailed(error.message);
}
github paambaati / codeclimate-action / src / main.ts View on Github external
throw new Error(`Coverage run exited with code ${lastExitCode}`);
      }
      debug('✅ Coverage run completed...');
    } catch (err) {
      error(err);
      setFailed('🚨 Coverage run failed!');
      return reject(err);
    }
    try {
      const commands = ['after-build', '--exit-code', lastExitCode.toString()];
      if (codeClimateDebug === 'true') commands.push('--debug');
      await exec(executable, commands, execOpts);
      debug('✅ CC Reporter after-build checkin completed!');
      return resolve();
    } catch (err) {
      error(err);
      setFailed('🚨 CC Reporter after-build checkin failed!');
      return reject(err);
    }
  });
}
github deliverybot / deployment-status / index.js View on Github external
...context.repo,
      deployment_id: context.payload.deployment.id,
      state,
      log_url: url,
      target_url: url,
      description,
    };
    if (env) {
      params.environment = env;
    }
    if (envUrl) {
      params.environment_url = envUrl;
    }
    await client.repos.createDeploymentStatus(params);
  } catch (error) {
    core.error(error);
    core.setFailed(error.message);
  }
}
github anchore / scan-action / index.js View on Github external
core.info('\nAnalyzing image: ' + imageReference);
        await exec(cmd);

        let rawdata = fs.readFileSync('./anchore-reports/policy_evaluation.json');
        let policyEval = JSON.parse(rawdata);
        let imageId = Object.keys(policyEval[0]);
        let imageTag = Object.keys(policyEval[0][imageId[0]]);
        let policyStatus = policyEval[0][imageId[0]][imageTag][0]['status'];

        try {
            let billOfMaterials = {
                "packages": mergeResults(loadContent(findContent("./anchore-reports/")))
            };
            fs.writeFileSync(billOfMaterialsPath, JSON.stringify(billOfMaterials));
        } catch (error) {
            core.error("Error constructing bill of materials from anchore output: " + error);
            throw error;
        }

        core.setOutput('billofmaterials', billOfMaterialsPath);
        core.setOutput('vulnerabilities', './anchore-reports/vulnerabilities.json');
        core.setOutput('policycheck', policyStatus);

        if (failBuild === "true" && policyStatus === "fail") {
            core.setFailed("Image failed Anchore policy evaluation");
        }

    } catch (error) {
        core.setFailed(error.message);
    }
}
github microsoft / BotFramework-Composer / .github / actions / conventional-pr / src / conventional-pr.ts View on Github external
const branchErrors = validateBaseBranch(pr.title, pr.baseRefName);

      if (titleErrors.length) {
        core.setFailed(titleErrors.join('\n'));
      }

      if (bodyErrors.length) {
        core.setFailed(bodyErrors.join('\n'));
      }

      if (branchErrors.length) {
        core.setFailed(branchErrors.join('\n'));
      }
    }
  } catch (err) {
    core.error(err);
    core.setFailed('Error getting Pull Request data.');
  }
}
github maierj / fastlane-action / .github / actions / statistics-chart-action / main.js View on Github external
function setFailed(error) {
    core.error(error);
    core.setFailed(error.message);
}
github Azure / webapps-deploy / src / deploymentProvider / WebAppDeploymentProvider.ts View on Github external
private async initializeForPublishProfile() {
        let scmCreds: scmCredentials;
        try {
            scmCreds = await this.getCredsFromXml(TaskParameters.getTaskParams().publishProfileContent);
        } catch(error) {
            core.error("Failed to fetch credentials from Publish Profile. For more details on how to set publish profile credentials refer https://aka.ms/create-secrets-for-GitHub-workflows");
            throw error;
        }

        this.kuduService = new Kudu(scmCreds.uri, scmCreds.username, scmCreds.password);
        this.kuduServiceUtility = new KuduServiceUtility(this.kuduService);
    }