[go: nahoru, domu]

Skip to content

Commit

Permalink
Trusted Partners PR - Auto Label and Assign for PRs from Intel
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 444596858
  • Loading branch information
tensorflower-gardener committed Apr 26, 2022
1 parent adf698b commit 9f0dd34
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/trusted-partners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

name: For CLs coming from trusted partners, Auto run tests and mark ready for pull.
on:
pull_request:

jobs:
auto-assign-intel:
runs-on: ubuntu-latest
if: |
github.event.sender.type == 'User' &&
endsWith(github.event.sender.email, '@intel.com')
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Trusted-Partners-PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const script = require('./.github/workflows/trusted_partners.js')
console.log(await script.intel({github, context}))
58 changes: 58 additions & 0 deletions .github/workflows/trusted_partners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

/** For trusted parters, we want to auto-run tests and mark the PR as ready to pull
This allows us to reduce the delay to external partners
@param {!object}
github enables querying for PR and also create issue using rest endpoint
context has the commit message details in the payload
@return {string} Returns the issue number and title
*/

const intel_action = async ({github, context}) => {
// Add Labels - kokoro:force-run, ready to pull
// The PR is also assigned to Mihai so it doesn't have to wait for assignment
// Additional reviewers can be added manually based on PR contents
const labels = ['kokoro:force-run', 'ready to pull'];
const assignees = ['mihaimaruseac'];
const resp_label = await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
});
if (resp_label.status >= 400) {
console.log(resp_label);
throw "Error adding labels to PR";
}
const resp_assign = await github.rest.issues.addAssignees({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: assignees
});
if (resp_assign.status >= 400) {
console.log(resp_assign);
throw "Error adding assignee to PR";
}
return `PR Updated successfully with Labels: ${labels} with Assignees: ${assignees}`;
};

module.exports = {
intel: intel_action
};

0 comments on commit 9f0dd34

Please sign in to comment.