From 43f09448f52ac64d9027f2d2856fe1bdcd4a0bbd Mon Sep 17 00:00:00 2001 From: Alex Bueno Date: Thu, 16 May 2024 11:36:40 +0200 Subject: [PATCH 1/6] Remove wrong md (#1773) --- changelog-versions/Vivo_a11y.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 changelog-versions/Vivo_a11y.md diff --git a/changelog-versions/Vivo_a11y.md b/changelog-versions/Vivo_a11y.md deleted file mode 100644 index e69de29bb2d..00000000000 From 6f04c3f907d28c61074ca666730b8e05af68eef4 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 16 May 2024 09:36:54 +0000 Subject: [PATCH 2/6] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd514b931e9..2440a6253fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Figma Changelog +[13.3.0](changelog-versions/13.3.0.md) + [13.2.0](changelog-versions/13.2.0.md) [13.1.0](changelog-versions/13.1.0.md) From e3959ec53d63377ba90b17ff3643c35073a6d32b Mon Sep 17 00:00:00 2001 From: Yayo Date: Fri, 17 May 2024 00:22:49 +0200 Subject: [PATCH 3/6] test --- .github/scripts/label_discussion.py | 61 ++++++++++++++++++++++++++ .github/workflows/label-discussion.yml | 26 +++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .github/scripts/label_discussion.py create mode 100644 .github/workflows/label-discussion.yml diff --git a/.github/scripts/label_discussion.py b/.github/scripts/label_discussion.py new file mode 100644 index 00000000000..e596f55b64b --- /dev/null +++ b/.github/scripts/label_discussion.py @@ -0,0 +1,61 @@ +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}" + +# Get discussion data from environment variable +event_path = os.getenv('GITHUB_EVENT_PATH') +with open(event_path) as f: + discussion = json.load(f) + +discussion_id = discussion['discussion']['node_id'] +discussion_title = discussion['discussion']['title'] +discussion_body = discussion['discussion']['body'] + +# 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) \ No newline at end of file diff --git a/.github/workflows/label-discussion.yml b/.github/workflows/label-discussion.yml new file mode 100644 index 00000000000..40f650dc7dc --- /dev/null +++ b/.github/workflows/label-discussion.yml @@ -0,0 +1,26 @@ +name: Label Discussions + +on: + discussion: + types: [created] + +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: Run labeling script + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: python .github/scripts/label_discussion.py From 477f0d71da2a52478393941833f6b5edb1afac62 Mon Sep 17 00:00:00 2001 From: Yayo Date: Fri, 17 May 2024 00:25:54 +0200 Subject: [PATCH 4/6] Update label-discussion.yml --- .github/workflows/label-discussion.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/label-discussion.yml b/.github/workflows/label-discussion.yml index 40f650dc7dc..6b61261c2cd 100644 --- a/.github/workflows/label-discussion.yml +++ b/.github/workflows/label-discussion.yml @@ -3,6 +3,8 @@ name: Label Discussions on: discussion: types: [created] + discussion_comment: + types: [created] jobs: label_discussion: @@ -22,5 +24,5 @@ jobs: - name: Run labeling script env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.NOVUM_PRIVATE_REPOS }} run: python .github/scripts/label_discussion.py From d9546f9de80a531f59f0ef2cde18b8276c639109 Mon Sep 17 00:00:00 2001 From: Yayo Date: Fri, 17 May 2024 00:27:15 +0200 Subject: [PATCH 5/6] Update label_discussion.py --- .github/scripts/label_discussion.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/scripts/label_discussion.py b/.github/scripts/label_discussion.py index e596f55b64b..6a682f8fcfc 100644 --- a/.github/scripts/label_discussion.py +++ b/.github/scripts/label_discussion.py @@ -7,14 +7,29 @@ TOKEN = os.getenv('NOVUM_PRIVATE_REPOS') API_URL = f"https://api.github.com/repos/{REPO}" -# Get discussion data from environment variable +# 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: - discussion = json.load(f) + event_data = json.load(f) -discussion_id = discussion['discussion']['node_id'] -discussion_title = discussion['discussion']['title'] -discussion_body = discussion['discussion']['body'] +# 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(): @@ -58,4 +73,4 @@ def determine_label(title, body, labels): label_to_apply = determine_label(discussion_title, discussion_body, existing_labels) if label_to_apply: - apply_label(label_to_apply) \ No newline at end of file + apply_label(label_to_apply) From 3e8eac04ebaf438821121245b801821aee2357b0 Mon Sep 17 00:00:00 2001 From: Yayo Date: Fri, 17 May 2024 00:31:27 +0200 Subject: [PATCH 6/6] Update label-discussion.yml --- .github/workflows/label-discussion.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/label-discussion.yml b/.github/workflows/label-discussion.yml index 6b61261c2cd..fb4153b80c0 100644 --- a/.github/workflows/label-discussion.yml +++ b/.github/workflows/label-discussion.yml @@ -2,9 +2,9 @@ name: Label Discussions on: discussion: - types: [created] + types: [created, edited] discussion_comment: - types: [created] + types: [created, edited] jobs: label_discussion: @@ -22,7 +22,10 @@ jobs: - name: Install dependencies run: pip install requests + - name: Debug environment variables + run: env + - name: Run labeling script env: - GITHUB_TOKEN: ${{ secrets.NOVUM_PRIVATE_REPOS }} + NOVUM_PRIVATE_REPOS: ${{ secrets.NOVUM_PRIVATE_REPOS }} run: python .github/scripts/label_discussion.py