Update service methods with variable initialization #15769
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Test Label Manager | |
on: | |
pull_request_target: | |
branches: [ main ] | |
types: [ opened, synchronize, reopened ] | |
jobs: | |
pr_test_label_manager: | |
name: PR Test Label Manager | |
runs-on: ubuntu-latest | |
if: | | |
github.event_name == 'pull_request_target' && | |
contains(fromJson('["opened", "synchronize", "reopened"]'), github.event.action) | |
steps: | |
- name: "Check Membership and Label PR" | |
uses: actions/github-script@v6 | |
id: check-membership | |
with: | |
github-token: ${{ secrets.PR_TOKEN }} | |
script: | | |
let prNumber = context.payload.pull_request && context.payload.pull_request.number; | |
try { | |
await github.rest.issues.removeLabel({owner: "viamrobotics", repo: "rdk", issue_number: prNumber, name: "safe to test"}); | |
} catch (err) { | |
core.info(`Non-fatal error ${err}, while trying to remove 'safe to test' label.`); | |
} | |
let orgResp = await github.rest.orgs.checkMembershipForUser({org: "viamrobotics", username: context.payload.sender.login}); | |
if (orgResp.status === 204) { | |
// order of labeling events must be preserved, so two seperate calls | |
await github.rest.issues.addLabels({owner: "viamrobotics", repo: "rdk", issue_number: prNumber, labels: ["safe to test"]}); | |
return true; | |
} | |
return false; | |
- name: Add Unsafe PR Comment | |
if: steps.check-membership.outputs.result != 'true' | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
recreate: true | |
message: For security reasons, this PR must be labeled with `safe to test` in order for tests to run. |