-
Notifications
You must be signed in to change notification settings - Fork 38
44 lines (41 loc) · 1.45 KB
/
add-new-pr-to-oss-triaging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Add any new Pull Request to OSS Triaging project
on:
pull_request_target:
types: [opened, reopened]
env:
EXTERNAL_PR_LABEL: external-contributor
PROJECT_URL: https://github.com/orgs/stackrox/projects/2 # OSS Triaging board
jobs:
check-pr-if-external:
name: Add external label to pull request if outside StackRox
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
BASE_REPO: ${{ github.repository }}
HEAD_REPO: ${{ github.event.pull_request.head.user.login }}/${{ github.event.pull_request.head.repo.name }}
outputs:
is_external_pr: ${{ steps.check-external-pr.outputs.is_external_pr }}
steps:
- name: Check out code
uses: actions/checkout@v3
- id: check-external-pr
run: |
set -uo pipefail
if [[ $BASE_REPO != $HEAD_REPO ]]; then
echo "::set-output name=is_external_pr::true"
gh pr edit \
${{ github.event.pull_request.number }} \
--add-label ${EXTERNAL_PR_LABEL}
else
echo "::set-output name=is_external_pr::false"
fi
add-to-project:
name: Add pull request to project
runs-on: ubuntu-latest
needs: [check-pr-if-external]
if: needs.check-pr-if-external.outputs.is_external_pr == 'true'
steps:
- uses: actions/[email protected]
with:
project-url: ${{ env.PROJECT_URL }}
github-token: ${{ secrets.ADD_TO_PROJECT_TOKEN }}