diff --git a/.github/workflows/pull_workflow.yaml b/.github/workflows/pull_workflow.yaml index f65c10bdb..2d0247b43 100644 --- a/.github/workflows/pull_workflow.yaml +++ b/.github/workflows/pull_workflow.yaml @@ -12,8 +12,8 @@ jobs: welcome: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/github-script@v6 + - uses: actions/checkout@v4 + - uses: actions/github-script@v7 with: script: | const script = require('./\.github/workflows/scripts/pull_workflow.js') diff --git a/.github/workflows/scripts/pull_workflow.js b/.github/workflows/scripts/pull_workflow.js index cafcf386e..5c8308440 100644 --- a/.github/workflows/scripts/pull_workflow.js +++ b/.github/workflows/scripts/pull_workflow.js @@ -60,28 +60,43 @@ module.exports = async ({github, context}) => { 'Github event: pull_request updated with new code for PR number = ', context.issue.number); const labelsToRemove = 'ready to pull'; - return github.rest.issues.removeLabel({ + let result; + try { + result = await github.rest.issues.removeLabel({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, name: labelsToRemove, }); + console.log(`'${labelsToRemove}' label removed successfully.\n`); + } + catch(e){ + console.log(`'${labelsToRemove}' label dosen't exist in the PR. \n`); + result = `'${labelsToRemove}' label dosen't exist in the PR.`; + } + return result; } else if (context.payload.action == 'closed') { console.log('Trigger Event: ', context.payload.action); console.log( 'Github event: pull_request updated with new code for PR number =', context.payload.pull_request.number); const labelsToRemove = ['keras-team-review-pending','ready to pull']; - let status = []; + let result = []; for(let label of labelsToRemove){ - let result = github.rest.issues.removeLabel({ + try { + let response = await github.rest.issues.removeLabel({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, name: label, }); - status.push(result); + result.push(response); + } + catch(e){ + console.log(`'${label}' label dosen't exist in the PR. \n`); + result.push( `'${label}' label dosen't exist in the PR.`); + } } - return status; + return result; } }; \ No newline at end of file