diff --git a/.github/branch-table/branch-table.py b/.github/branch-table/branch-table.py new file mode 100644 index 00000000000..697a06728c3 --- /dev/null +++ b/.github/branch-table/branch-table.py @@ -0,0 +1,125 @@ +import requests +import pandas as pd +import os +import re + +# Function to get the files from specific Figma projects +def get_figma_project_files(project_ids, figma_token): + headers = { + "X-Figma-Token": figma_token + } + file_keys = [] + + for project_id in project_ids: + print(f"Fetching files for project ID: {project_id}") + project_files_url = f"https://api.figma.com/v1/projects/{project_id}/files" + files_response = requests.get(project_files_url, headers=headers) + + if files_response.status_code == 200: + files = files_response.json().get("files", []) + for file in files: + file_keys.append({"key": file["key"], "name": file["name"]}) + else: + print(f"Error fetching files for project {project_id}: {files_response.status_code}") + + return file_keys + +# Function to get information from a Figma file, using the branch_data=true parameter +def get_figma_file_data(file_key, figma_token): + headers = { + "X-Figma-Token": figma_token + } + url = f"https://api.figma.com/v1/files/{file_key}?branch_data=true" + response = requests.get(url, headers=headers, verify=True) + + if response.status_code == 200: + return response.json() + else: + print(f"Error fetching data for file {file_key}: {response.status_code}") + return None + +# Function to process files and generate a table with the desired information +def analyze_files(file_keys, figma_token): + table_data = [] + + for file in file_keys: + file_key = file["key"] + file_name = file["name"] + file_data = get_figma_file_data(file_key, figma_token) + + if file_data: + branches = file_data.get("branches", []) + num_branches = len(branches) + + # Only add the file if it has branches + if num_branches > 0: + first_branch = True + for branch in branches: + branch_name = branch["name"] + branch_link = f"[{branch_name}](https://www.figma.com/file/{file_key}/branch/{branch['key']})" + + # Extract the issue number using regex + issue_match = re.match(r"#(\d+)", branch_name) + issue_number = "#" + issue_match.group(1) if issue_match else "" + + table_data.append({ + "File Name": file_name if first_branch else "", + "Branches": num_branches if first_branch else "", + "Branch Names": branch_link, + "Issue": issue_number + }) + + # After the first branch, set first_branch to False + first_branch = False + + # Create a DataFrame with the collected information + df = pd.DataFrame(table_data) + return df + +# Function to update the issue on GitHub +def update_github_issue(issue_number, repo_owner, repo_name, markdown_content, github_token): + url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/issues/{issue_number}" + headers = { + "Authorization": f"token {github_token}", + "Accept": "application/vnd.github.v3+json" + } + data = { + "body": markdown_content + } + + response = requests.patch(url, json=data, headers=headers) + + if response.status_code == 200: + print("Issue updated successfully") + else: + print(f"Failed to update issue: {response.status_code} - {response.text}") + +# Personal access token for Figma and GitHub APIs +figma_token = os.getenv("FIGMA_TOKEN") +github_token = os.getenv("GITHUB_TOKEN") + +# List of project IDs to fetch files from +project_ids = [ + "25719143", # Mística Libraries + "266390224", # Mística Skins Libraries + "27955986", # Specs + "170790970", # Community Specs + "30110755" # Materials + # Add more project id here +] + +# Fetch all file keys from the specified Figma projects +file_keys = get_figma_project_files(project_ids, figma_token) + +# Analyze the files and generate the table +df = analyze_files(file_keys, figma_token) + +# Convert the table to markdown format +markdown_table = df.to_markdown(index=False) + +# Update the issue on GitHub +repo_owner = "Telefonica" +repo_name = "mistica-design" +issue_number = 1927 # Change this number to the issue number you want to update + +update_github_issue(issue_number, repo_owner, repo_name, markdown_table, github_token) diff --git a/.github/workflows/archived/auto-release.yml b/.github/workflows/archived/auto-release.yml deleted file mode 100644 index fe20c825d9a..00000000000 --- a/.github/workflows/archived/auto-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: "Release" - -on: - push: - branches: - - "production" - -jobs: - pre-release: - name: "Release" - runs-on: "ubuntu-latest" - - steps: - # ... - - name: "Build & test" - run: | - echo "done!" - - - uses: "marvinpinto/action-automatic-releases@latest" - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "${{github.event.commits[0].message}}" - prerelease: false - title: "${{github.event.commits[0].message}}" - files: | - LICENSE.txt - *.jar diff --git a/.github/workflows/archived/issue-task-reminder.yml b/.github/workflows/archived/issue-task-reminder.yml deleted file mode 100644 index f642cca0844..00000000000 --- a/.github/workflows/archived/issue-task-reminder.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Pending task notification - -on: - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: allanwsilva/check-pending-tasks@v1.0.0 - with: - sendgrid-from-email: ignacio.ceballostorres@telefonica.com - email-subject: "Check out these Github tasks assigned to you that are still pending" - env: - GITHUB_TOKEN: ${{ secrets.NOVUM_PRIVATE_REPOS }} - SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} diff --git a/.github/workflows/archived/jira-issues.yml b/.github/workflows/archived/jira-issues.yml deleted file mode 100644 index 5b520281e39..00000000000 --- a/.github/workflows/archived/jira-issues.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Jira Sync - -on: - issues: - types: [opened, labeled, unlabeled] - issue_comment: - types: [created] - -jobs: - sync: - name: Sync Items - runs-on: ubuntu-latest - steps: - - name: Sync - uses: mheap/github-action-issue-to-jira@v1 - env: - GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }} - with: - jiraHost: ${{ secrets.JIRA_HOST }} - jiraUsername: ${{ secrets.JIRA_USERNAME }} - jiraPassword: ${{ secrets.JIRA_PASSWORD }} # See https://id.atlassian.com/manage/api-tokens - project: DSNCORE - assignee: ${{ secrets.JIRA_USERNAME }} diff --git a/.github/workflows/archived/new-component-notification.yml b/.github/workflows/archived/new-component-notification.yml deleted file mode 100644 index ba9e7938270..00000000000 --- a/.github/workflows/archived/new-component-notification.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: New component request notification - -on: - issues: - types: [labeled] - -jobs: - build: - # runs-on: [self-hosted, Linux] - runs-on: ubuntu-latest - if: (github.event.label.name == '✨ Component request') || (github.event.label.name == '✨ Component request') - - steps: - - uses: actions/checkout@v2 - - uses: timheuer/issue-notifier@v1 - env: - SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} - with: - fromMailAddress: 'ignacio.ceballostorres@telefonica.com' - toMailAddress: 'yceballost@gmail.com' - subject: 'A new component request!' - labelsToMonitor: '✨ Component request' diff --git a/.github/workflows/archived/new-issue-label.yml b/.github/workflows/archived/new-issue-label.yml deleted file mode 100644 index 8b216aef7a1..00000000000 --- a/.github/workflows/archived/new-issue-label.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Bug reported - -on: - workflow_dispatch: - issues: - types: [labeled] - -jobs: - Move_Labeled_Issue_On_Project_Board: - runs-on: ubuntu-latest - steps: - - uses: konradpabjan/move-labeled-or-milestoned-issue@v2.0 - with: - action-token: "${{ secrets.PERSONAL_TOKEN }}" - project-url: "https://github.com/Telefonica/mistica-design/projects/2" - column-name: "Bugs reported" - label-name: "bug 🐞" diff --git a/.github/workflows/archived/send-files.yml b/.github/workflows/archived/send-files.yml deleted file mode 100644 index 5076786e258..00000000000 --- a/.github/workflows/archived/send-files.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Cloning libraries to mistica-sketch-libraries - -on: - push: - branches: - - production - paths: - - 'libs/**' - # - '.github/workflows/sendFiles.yml' - -jobs: - send-files: - # runs-on: [self-hosted, Linux] - runs-on: ubuntu-latest - steps: - # comando solo para Self-Hosted machines - # - run: sudo chown -R $USER:$USER /home/pi/actions-github/mistica-design-libraries/_work/ - - - name: Cleanup - run: | - sudo chown -R $USER:$USER $GITHUB_WORKSPACE - - # Checkout para self-hosted Telefonica - - uses: actions/checkout@v2 - - - name: Get branch name - uses: rlespinasse/github-slug-action@v3.x - - - name: Copy Brands to ${{ env.GITHUB_REF_SLUG_URL }} - uses: andstor/copycat-action@v3.2.3 - with: - personal_token: ${{ secrets.PERSONAL_TOKEN }} - src_branch: ${{ env.GITHUB_REF_SLUG_URL }} - src_path: libs/. - dst_branch: ${{ env.GITHUB_REF_SLUG_URL }} - dst_path: libraries/. - dst_owner: yceballost - dst_repo_name: mistica-sketch-libraries - commit_message: Libs uploaded to ${{ env.GITHUB_REF_SLUG_URL }} - clean: true \ No newline at end of file diff --git a/.github/workflows/archived/sendBrands.yml b/.github/workflows/archived/sendBrands.yml deleted file mode 100644 index 2709b9cefa1..00000000000 --- a/.github/workflows/archived/sendBrands.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Cloning brands to mistica-sketch-libraries - -on: - schedule: - - cron: "03 03 * * *" - -jobs: - copy: - runs-on: self-hosted - steps: - - - name: Sleep for 90 seconds - uses: jakejarvis/wait-action@master - with: - time: '90s' - - - name: Get branch name - uses: rlespinasse/github-slug-action@v2.x - - - name: Copy Brands (${{ env.GITHUB_REF_SLUG_URL }}) - uses: andstor/copycat-action@v3 - with: - personal_token: ${{ secrets.PERSONAL_TOKEN }} - src_branch: ${{ env.GITHUB_REF_SLUG_URL }} - src_path: /Brand Libraries/. - dst_branch: ${{ env.GITHUB_REF_SLUG_URL }} - dst_path: /BrandLibraries/. - dst_owner: yceballost - dst_repo_name: mistica-sketch-libraries - commit_message: Brands uploaded - clean: true diff --git a/.github/workflows/archived/sendComponents.yml b/.github/workflows/archived/sendComponents.yml deleted file mode 100644 index 9b36785c666..00000000000 --- a/.github/workflows/archived/sendComponents.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Cloning folder libraries to mistica-sketch-libraries — PRODUCTION - -on: - push: - schedule: - - cron: "03 03 * * *" - -jobs: - copy: - runs-on: self-hosted - steps: - - - name: Get branch name - uses: rlespinasse/github-slug-action@v2.x - - - name: Copy Components (${{ env.GITHUB_REF_SLUG_URL }}) - uses: andstor/copycat-action@v3 - with: - personal_token: ${{ secrets.PERSONAL_TOKEN }} - src_branch: ${{ env.GITHUB_REF_SLUG_URL }} - src_path: /Component Libraries/. - dst_branch: ${{ env.GITHUB_REF_SLUG_URL }} - dst_path: /ComponentLibraries/. - dst_owner: yceballost - dst_repo_name: mistica-sketch-libraries - commit_message: Components uploaded - clean: true diff --git a/.github/workflows/archived/sendFiles.yml b/.github/workflows/archived/sendFiles.yml deleted file mode 100644 index a7e88896988..00000000000 --- a/.github/workflows/archived/sendFiles.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Cloning libraries to mistica-sketch-libraries - -on: - push: - branches: - - production - -jobs: - # generator: - # runs-on: [self-hosted, macOS] - # steps: - - # - uses: actions/checkout@v2 - - # - name: Inject slug/short variables - # uses: rlespinasse/github-slug-action@v3.x - - # - run: npm install --global kactus-cli --force - - # - name: convert folder to sketch file - # run: | - # kactus import libs/Movistar - # kactus import libs/O2 - # kactus import libs/ClassicO2 - # kactus import libs/Vivo - # kactus import libs/Telefonica - # kactus import libs/Mistica\ iOS - # kactus import libs/Mistica\ Android - - # # - name: stage changed files - # # run: git add -f . - - # # - name: config - # # run: | - # # git config --global user.name "🤖GeneratorBot" - # # git config --global user.email "users.noreply.github.com" - - # # - name: commit changed files - # # run: git commit -m "sketch generated and folders removed" - - # # - name: push code to ${{ env.GITHUB_REF_SLUG_URL }} - # # run: git push origin HEAD:${{ env.GITHUB_REF_SLUG_URL }} - - send-files: - # needs: generator - runs-on: [self-hosted, Linux] - steps: - # comando solo para Self-Hosted machines - # - run: sudo chown -R $USER:$USER /home/pi/actions-github/mistica-design-libraries/_work/ - - - name: Get branch name - uses: rlespinasse/github-slug-action@v2.x - - - name: Copy Brands to ${{ env.GITHUB_REF_SLUG_URL }} - uses: andstor/copycat-action@v3.2.3 - with: - personal_token: ${{ secrets.PERSONAL_TOKEN }} - src_branch: ${{ env.GITHUB_REF_SLUG_URL }} - src_path: libs/. - dst_branch: ${{ env.GITHUB_REF_SLUG_URL }} - dst_path: libraries/. - dst_owner: yceballost - dst_repo_name: mistica-sketch-libraries - commit_message: Libs uploaded to ${{ env.GITHUB_REF_SLUG_URL }} - clean: true - - # - name: removed sketch force - # run: | - # git rm *.sketch - # git commit -m "sketch removed" - # git push origin HEAD:${{ env.GITHUB_REF_SLUG_URL }} diff --git a/.github/workflows/dashboard.yml b/.github/workflows/dashboard.yml deleted file mode 100644 index 63e52c47e89..00000000000 --- a/.github/workflows/dashboard.yml +++ /dev/null @@ -1,153 +0,0 @@ -name: Build Dashboard - -on: - # push: - # paths: - # - ".github/workflows/dashboard.yml" - # issues: - # types: [opened, closed, reopened] - -jobs: - build-dashboard: - runs-on: ubuntu-latest - - steps: - - name: Cleanup - run: | - sudo chown -R $USER:$USER $GITHUB_WORKSPACE - - - name: Check out repository - uses: actions/checkout@v2 - - name: Check out GitHub Pages branch - uses: actions/checkout@v2 - with: - ref: "gh-pages" - path: "./dashboard" - - - name: "Generate Dashboard" - uses: ethomson/issue-dashboard@v1 - with: - config: | - output: - format: html - filename: 'dashboard/index.html' - - sections: - - title: 'Open Issues by Type' - description: 'Queries of issues by type, using their label.' - widgets: - - type: 'number' - title: 'New components' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"New component 🔸"' - color: 'tertiary' - - type: 'number' - title: 'Component requests' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"request ✨"' - color: 'primary' - - type: 'number' - title: 'Bugs' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"bug 🐞"' - color: 'secondary' - - type: 'table' - title: 'New components list' - fields: - - title: 'Issue' - property: 'number' - - title: 'Date' - value: '{{ date(item.created_date) }}' - - title: 'Title' - property: 'title' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"New component 🔸"' - limit: 15 - - type: 'table' - title: 'Component request list' - fields: - - title: 'Issue' - property: 'number' - - title: 'Date' - value: '{{ date(item.created_date) }}' - - title: 'Title' - property: 'title' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"request ✨"' - limit: 15 - - type: 'table' - title: 'Bugs list' - fields: - - title: 'Issue' - property: 'number' - - title: 'Date' - value: '{{ date(item.created_date) }}' - - title: 'Title' - property: 'title' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"bug 🐞"' - limit: 15 - - - title: 'Open Issues by Age' - description: 'Queries of open issues by their creation date.' - widgets: - - type: 'graph' - title: 'Age' - elements: - - title: '7 days' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue created:>{{ date("-7 days") }}' - color: 'primary' - - title: '15 days' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue created:>{{ date("-15 days") }}' - color: 'primary' - - title: '30 days' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue created:{{ date("-30 days") }}..{{ date("-7 days") }}' - color: 'primary' - - title: '90 days' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue created:{{ date("-90 days") }}..{{ date("-30 days") }}' - - title: '180 days' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue created:{{ date("-180 days") }}..{{ date("-60 days") }}' - - - - title: 'Pull Requests' - widgets: - - type: 'number' - title: 'Opened' - issue_query: 'repo:Telefonica/mistica-design is:open is:pr review:none' - color: 'secondary' - - type: 'table' - title: 'Open Pull Requests' - fields: - - title: 'Issue' - property: 'number' - - title: 'Date' - value: '{{ date(item.created_date) }}' - - title: 'Title' - property: 'title' - issue_query: 'repo:Telefonica/mistica-design is:open is:pr review:none sort:created-asc' - limit: 15 - token: ${{ github.token }} - - - name: "Generate bugs" - uses: ethomson/issue-dashboard@v1 - with: - config: | - output: - format: html - filename: 'dashboard/bugs.html' - - sections: - - title: 'Test' - widgets: - - type: 'number' - title: 'Bug' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"bug 🐞"' - color: 'primary' - - type: 'number' - title: 'Component Requests' - issue_query: 'repo:Telefonica/mistica-design is:open is:issue label:"request ✨"' - color: 'secondary' - token: ${{ github.token }} - - - name: Publish Documentation - run: | - git add . - git config user.name 'Dashboard User' - git config user.email 'nobody@nowhere' - git commit -m 'Documentation update' --allow-empty - git push origin gh-pages - working-directory: dashboard diff --git a/.github/workflows/open-branches.yml b/.github/workflows/open-branches.yml new file mode 100644 index 00000000000..131c6a98369 --- /dev/null +++ b/.github/workflows/open-branches.yml @@ -0,0 +1,31 @@ +name: Open branches in Figma + +on: + workflow_dispatch: + schedule: + - cron: 30 8 * * MON-FRI + +jobs: + sync-figma-brand: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + # Paso 3: Instalar dependencias de Python + - name: Install dependencies + run: | + pip install requests pandas + + - name: Run sync for the brand(s) + env: + FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }} + GITHUB_TOKEN: ${{ secrets.NOVUM_PRIVATE_REPOS }} + working-directory: .github/branch-table + run: python3 branch-table.py