Skip to content

(WIP) Resource table v2 #4729

(WIP) Resource table v2

(WIP) Resource table v2 #4729

Workflow file for this run

# This GitHub Actions workflow is designed to automatically check pull requests in the cBioPortal repository for valid labels before they can be merged.
# The workflow ensures that pull requests have labels that are defined in the .github/release-drafter.yml file's "categories" section.
# If a pull request lacks a valid label, the workflow will fail, preventing the merge until valid labels are applied.
name: Label Check
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
jobs:
label-check:
runs-on: ubuntu-latest
steps:
- name: Check PR Labels
uses: actions/checkout@v2
- name: Install dependencies
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.34.2/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
- name: Get Labels from release-drafter.yml
id: get_labels
run: |
yq -r '.categories[].labels[]' .github/release-drafter.yml > labels.txt
- name: Check Labels
id: check_labels
run: |
PR_NUMBER=$(jq -r ".number" $GITHUB_EVENT_PATH)
PR_LABELS_STRING=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | \
jq -r '.labels[].name')
mapfile -t PR_LABELS <<< "$PR_LABELS_STRING"
mapfile -t AVAILABLE_LABELS < labels.txt
pr_label_index=0
while [ $pr_label_index -lt ${#PR_LABELS[@]} ] ; do
pr_label="${PR_LABELS[$pr_label_index]}"
if [[ "$pr_label" == "skip-changelog" || "$pr_label" == "cl-skip-changelog" ]] ; then
echo "PR contains a valid label: $pr_label"
exit 0 # Valid label found, exit successfully
fi
available_label_index=0
while [ $available_label_index -lt ${#AVAILABLE_LABELS[@]} ] ; do
available_label="${AVAILABLE_LABELS[$available_label_index]}"
if [[ "$available_label" == "$pr_label" ]] ; then
echo "PR contains a valid label: $pr_label"
exit 0 # Valid label found, exit successfully
fi
available_label_index=$(($available_label_index+1))
done
pr_label_index=$(($pr_label_index+1))
done
echo "No valid label found on PR."
echo "Available label options from release-drafter.yml:"
cat labels.txt
exit 1 # No valid label found, exit with an error