function writeToGitHub()

in src/utils.ts [80:107]


function writeToGitHub(config: Config) {
    if (config.accessToken) {
        process.stdout.write("Creating file via Octokit\n");

        const context = github.context
        const octokit = github.getOctokit(config.accessToken);
        const contents = fs.readFileSync(COVERAGE_SVG, {encoding: 'base64'});

        octokit.rest.repos.getContent({
            owner: context.repo.owner,
            repo: context.repo.repo,
            path: COVERAGE_SVG
        }).then(value => {
            if ('data' in value && 'sha' in value.data) {
                const sha: string = value.data.sha as string
                if (sha) {
                    updateOrCreateFile(config.accessToken, contents, sha)
                }
            } else {
                core.warning("Failed to get hash from file, attempting a new file.")
                throw(new Error("Failed to get hash"))
            }
        }).catch(r => {
            process.stdout.write(fmt.sprintf("Attempting to create file: %s\n", r.message));
            updateOrCreateFile(config.accessToken, contents, '')
        })
    }
}