Skip to content

Commit

Permalink
The workflow no longer throws an error if a labels are absent in the …
Browse files Browse the repository at this point in the history
…PR. Updated package version to address warnings.

PiperOrigin-RevId: 606592190
  • Loading branch information
tensorflower-gardener committed Feb 13, 2024
1 parent 01712a9 commit 9a4b4ba
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/scripts/pull_workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

0 comments on commit 9a4b4ba

Please sign in to comment.