import * as core from '@actions/core' ; import * as github from '@actions/github' ; import { RequestError } from '@octokit/request-error' ; import * as verifiedCommits from './dependabot/verified_commits' ; import * as updateMetadata from './dependabot/update_metadata' ; import * as output from './dependabot/output' ; export async function run ( ) { const token = core . getInput ( 'github-token' ) ; if ( ! token ) { core . setFailed ( 'github-token is not set! Please add \'github-token: "${{ secrets.GITHUB_TOKEN }}"\' to your workflow file.' ) ; return ; } try { const githubClient = github . getOctokit ( token ) ; const commitMessage = await verifiedCommits . getMessage ( githubClient , github . context ) ; if ( commitMessage ) { core . info ( 'Parsing Dependabot metadata' ) ; const updatedDependencies = updateMetadata . parse ( commitMessage ) ; if ( updatedDependencies . length > 0 ) { output . set ( updatedDependencies ) ; } else { core . setFailed ( 'PR does not contain metadata, nothing to do.' ) ; } } else { core . setFailed ( 'PR is not from Dependabot, nothing to do.' ) ; } } catch ( error ) { if ( error instanceof RequestError ) { core . setFailed ( `Api Error: (${ error . status }) ${ error . message }` ) ; return ; } core . setFailed ( error . message ) ; } } run ( ) ;