From 916b112453f1f5cfa8af83252ee8bb61d6f95924 Mon Sep 17 00:00:00 2001 From: Yayo Date: Mon, 20 May 2024 23:30:35 +0200 Subject: [PATCH] remove label workflow --- .github/scripts/label_discussion.py | 76 -------------------------- .github/workflows/label-discussion.yml | 31 ----------- 2 files changed, 107 deletions(-) delete mode 100644 .github/scripts/label_discussion.py delete mode 100644 .github/workflows/label-discussion.yml diff --git a/.github/scripts/label_discussion.py b/.github/scripts/label_discussion.py deleted file mode 100644 index 6a682f8fcf..0000000000 --- a/.github/scripts/label_discussion.py +++ /dev/null @@ -1,76 +0,0 @@ -import os -import json -import requests - -# GitHub repository and token -REPO = 'Telefonica/mistica-design' -TOKEN = os.getenv('NOVUM_PRIVATE_REPOS') -API_URL = f"https://api.github.com/repos/{REPO}" - -# Verifica si el token está presente -if not TOKEN: - raise ValueError("NOVUM_PRIVATE_REPOS no está configurado") - -# Depuración: Imprime los primeros caracteres del token -print(f"TOKEN: {TOKEN[:4]}...") - -# Get event data from environment variable -event_path = os.getenv('GITHUB_EVENT_PATH') -with open(event_path) as f: - event_data = json.load(f) - -# Determine if the event is a discussion or a discussion comment -if 'discussion' in event_data: - discussion_id = event_data['discussion']['node_id'] - discussion_title = event_data['discussion']['title'] - discussion_body = event_data['discussion']['body'] -elif 'comment' in event_data: - discussion_id = event_data['comment']['discussion_id'] - discussion_title = "" # Comments do not have a title - discussion_body = event_data['comment']['body'] -else: - raise ValueError("Evento no reconocido") - -# Function to get existing labels -def get_existing_labels(): - headers = { - 'Authorization': f'token {TOKEN}', - 'Accept': 'application/vnd.github.v3+json', - } - response = requests.get(f'{API_URL}/labels', headers=headers) - response.raise_for_status() - return [label['name'] for label in response.json()] - -# Function to apply label -def apply_label(label): - headers = { - 'Authorization': f'token {TOKEN}', - 'Accept': 'application/vnd.github.v3+json', - } - data = { - 'labels': [label] - } - response = requests.post(f'{API_URL}/discussions/{discussion_id}/labels', headers=headers, json=data) - response.raise_for_status() - -# Function to determine appropriate label -def determine_label(title, body, labels): - # Simple keyword matching for demonstration; improve with NLP techniques as needed - keywords_to_labels = { - 'bug': 'bug', - 'feature': 'enhancement', - 'question': 'question' - } - - for keyword, label in keywords_to_labels.items(): - if keyword in title.lower() or keyword in body.lower(): - if label in labels: - return label - return None - -# Main script logic -existing_labels = get_existing_labels() -label_to_apply = determine_label(discussion_title, discussion_body, existing_labels) - -if label_to_apply: - apply_label(label_to_apply) diff --git a/.github/workflows/label-discussion.yml b/.github/workflows/label-discussion.yml deleted file mode 100644 index fb4153b80c..0000000000 --- a/.github/workflows/label-discussion.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Label Discussions - -on: - discussion: - types: [created, edited] - discussion_comment: - types: [created, edited] - -jobs: - label_discussion: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - - name: Install dependencies - run: pip install requests - - - name: Debug environment variables - run: env - - - name: Run labeling script - env: - NOVUM_PRIVATE_REPOS: ${{ secrets.NOVUM_PRIVATE_REPOS }} - run: python .github/scripts/label_discussion.py