Files
TheRock/rocm-systems/.github/workflows/pr-org-label.yml
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

73 lines
2.5 KiB
YAML

# Label PRs by Author Org Membership
# -------------
# This workflow is designed to automatically label pull requests based on the author's membership in the ROCm organization.
name: "Label PRs by Author Org Membership"
on:
workflow_dispatch:
schedule:
- cron: "*/30 * * * *" # every 30 minutes
jobs:
label-prs:
if: github.repository == 'ROCm/rocm-systems'
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
env:
ORG_TO_CHECK: ROCm
ORG_LABEL: "organization: ROCm"
EXTERNAL_LABEL: "external contribution"
steps:
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github
${{ github.event.inputs.subrepo-prefix }}
sparse-checkout-cone-mode: true
token: ${{ steps.generate-token.outputs.token }}
- name: Get open PR numbers
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh pr list --state open --json number,labels \
--jq '[.[] | select(
([.labels[].name] | index(env.ORG_LABEL) | not) and
([.labels[].name] | index(env.EXTERNAL_LABEL) | not)
) | .number] | .[]' \
> pr_numbers.txt
- name: Label PRs based on author membership
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
while read pr; do
echo "Checking PR #$pr"
labels=$(gh pr view "$pr" --json labels --jq '.labels[].name')
if echo "$labels" | grep -qFx "${{ env.ORG_LABEL }}" || echo "$labels" | grep -qFx "${{ env.EXTERNAL_LABEL }}"; then
echo "PR #$pr already labeled, skipping."
continue
fi
author=$(gh pr view "$pr" --json author --jq '.author.login')
if gh api orgs/${{ env.ORG_TO_CHECK }}/members/$author --silent; then
gh pr edit "$pr" --add-label "${{ env.ORG_LABEL }}"
else
gh pr edit "$pr" --add-label "${{ env.EXTERNAL_LABEL }}"
fi
done < pr_numbers.txt