|
| 1 | +# Copyright 2023 Specter Ops, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# SPDX-License-Identifier: Apache-2.0 |
| 16 | +name: PR-Ticket-OoOrg |
| 17 | + |
| 18 | +on: |
| 19 | + pull_request: |
| 20 | + types: [opened, synchronize] |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + runs-on: self-hosted |
| 25 | + steps: |
| 26 | + - name: Check if PR is from within the organization |
| 27 | + id: check_org |
| 28 | + run: |
| 29 | + PR_URL=$(jq -r .pull_request.url "$GITHUB_EVENT_PATH") |
| 30 | + PR_NUMBER=$(jq -r .pull_request.number "$GITHUB_EVENT_PATH") |
| 31 | + TEAM_SLUG="bloodhound-engineering" # Replace with your team's slug |
| 32 | + GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 33 | + PR_ORG=$(jq -r .pull_request.head.repo.organization.login "$GITHUB_EVENT_PATH") |
| 34 | + PR_USER=$(jq -r .pull_request.user.login "$GITHUB_EVENT_PATH") |
| 35 | + TEAM_MEMBERSHIP=$(curl -s -X GET -H "Authorization: token $GITHUB_TOKEN" \ |
| 36 | + "https://api.github.com/orgs/$PR_ORG/teams/$TEAM_SLUG/memberships/$PR_USER") |
| 37 | + |
| 38 | + env: |
| 39 | + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} |
| 40 | + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} |
| 41 | + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} |
| 42 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + |
| 44 | + if [ -z "$TEAM_MEMBERSHIP" ]; then |
| 45 | + - name: Login |
| 46 | + uses: atlassian/gajira-login@v3 |
| 47 | + - name: Jira Create |
| 48 | + uses: atlassian/gajira-create@v3 |
| 49 | + with: |
| 50 | + project: BP |
| 51 | + issuetype: 'Product Feature' |
| 52 | + summary: ${{ github.event.pulls.title }} |
| 53 | + description: "Github Pull Request Link: ${{ github.event.pulls.html_url}} \r\n ${{ github.event.pulls.body }}" |
| 54 | + fields: '{"labels":["GitHubReport"]}' |
| 55 | + |
0 commit comments