From 26b38dcdcab85ea44ac86b9b2637caeb9e0baacb Mon Sep 17 00:00:00 2001 From: JOY <5027251+JOY@users.noreply.github.com> Date: Mon, 3 Aug 2026 21:23:04 +0700 Subject: [PATCH 1/2] ci: remove obsolete project board workflows --- .github/workflows/project-management.yml | 111 --------- .github/workflows/update-project-cards.yml | 248 --------------------- 2 files changed, 359 deletions(-) delete mode 100644 .github/workflows/project-management.yml delete mode 100644 .github/workflows/update-project-cards.yml diff --git a/.github/workflows/project-management.yml b/.github/workflows/project-management.yml deleted file mode 100644 index 042242be13..0000000000 --- a/.github/workflows/project-management.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Project management -on: - issues: - types: [ closed ] - pull_request: - types: [ review_requested ] - -jobs: - not_planned_issue: - name: Update task for not planned issue - if: ${{ github.event.issue && github.event.action == 'closed' && github.event.issue.state_reason == 'not_planned' }} - uses: './.github/workflows/update-project-cards.yml' - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Done - issues: "[${{ github.event.issue.number }}]" - secrets: inherit - permissions: - issues: read - - completed_issue: - name: Update task for completed issue - if: ${{ github.event.issue && github.event.action == 'closed' && github.event.issue.state_reason == 'completed' }} - uses: './.github/workflows/update-project-cards.yml' - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Ready For Release - issues: "[${{ github.event.issue.number }}]" - secrets: inherit - permissions: - issues: read - - pr_linked_issues: - name: Get issues linked to PR - runs-on: ubuntu-latest - if: ${{ github.event.pull_request && github.event.action == 'review_requested' }} - outputs: - issues: ${{ steps.linked_issues.outputs.result }} - steps: - - name: Fetching issues linked to pull request - id: linked_issues - uses: actions/github-script@v7 - env: - PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} - with: - script: | - const response = await github.graphql(` - query ($owner: String!, $repo: String!, $pr: Int!) { - repository(owner: $owner, name: $repo) { - pullRequest(number: $pr) { - number - title - closingIssuesReferences(first: 100) { - nodes { - number - title - closed - } - } - } - } - } - `, { - owner: context.repo.owner, - repo: context.repo.repo, - pr: Number(process.env.PULL_REQUEST_NUMBER), - }); - - const { repository: { pullRequest: { closingIssuesReferences } } } = response; - const issues = closingIssuesReferences.nodes.map(({ number }) => number); - - if (!issues.length) { - core.notice(`No linked issues found for pull request #${ process.env.PULL_REQUEST_NUMBER }`); - return; - } - - core.info(`Found ${ issues.length } issue(s): ${ issues.join(', ') || '-' }`); - - return issues; - permissions: - issues: read - pull-requests: read - - issues_in_review: - name: Update status for issues in review - needs: [ pr_linked_issues ] - if: ${{ needs.pr_linked_issues.outputs.issues }} - uses: './.github/workflows/update-project-cards.yml' - secrets: inherit - with: - project_name: ${{ vars.PROJECT_NAME }} - field_name: Status - field_value: Review - issues: ${{ needs.pr_linked_issues.outputs.issues }} - permissions: - issues: read - - copy_labels: - name: Copy issues labels to pull request - needs: [ pr_linked_issues ] - if: ${{ needs.pr_linked_issues.outputs.issues }} - uses: './.github/workflows/copy-issues-labels.yml' - secrets: inherit - with: - pr_number: ${{ github.event.pull_request.number }} - issues: ${{ needs.pr_linked_issues.outputs.issues }} - permissions: - issues: read - pull-requests: write diff --git a/.github/workflows/update-project-cards.yml b/.github/workflows/update-project-cards.yml deleted file mode 100644 index 486dab672f..0000000000 --- a/.github/workflows/update-project-cards.yml +++ /dev/null @@ -1,248 +0,0 @@ -name: Update project cards for issues - -on: - workflow_dispatch: - inputs: - project_name: - description: Name of the project - default: Front-end tasks - required: true - type: string - field_name: - description: Field name to be updated - default: Status - required: true - type: string - field_value: - description: New value of the field - default: Released - required: true - type: string - issues: - description: JSON encoded list of issue numbers to be updated - required: true - type: string - workflow_call: - inputs: - project_name: - description: Name of the project - required: true - type: string - field_name: - description: Field name to be updated - required: true - type: string - field_value: - description: New value of the field - required: true - type: string - issues: - description: JSON encoded list of issue numbers to be updated - required: true - type: string - -permissions: - issues: read - -jobs: - run: - name: Run - runs-on: ubuntu-latest - steps: - - name: Getting project info - id: project_info - uses: actions/github-script@v7 - env: - PROJECT_NAME: ${{ inputs.project_name }} - FIELD_NAME: ${{ inputs.field_name }} - FIELD_VALUE: ${{ inputs.field_value }} - with: - github-token: ${{ secrets.BOT_LABEL_ISSUE_TOKEN }} - script: | - const response = await github.graphql(` - query ($login: String!, $q: String!) { - organization(login: $login) { - projectsV2(query: $q, first: 1) { - nodes { - id, - title, - number, - fields(first: 20) { - nodes { - ... on ProjectV2Field { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - options { - id - name - } - } - } - } - } - } - } - } - `, { - login: context.repo.owner, - q: process.env.PROJECT_NAME, - }); - - const { organization: { projectsV2: { nodes: projects } } } = response; - - if (projects.length === 0) { - core.setFailed('Project not found.'); - return; - } - - if (projects.length > 1) { - core.info(`Found ${ projects.length } with the similar name:`); - projects.forEach((issue) => { - core.info(` #${ projects.number } - ${ projects.title }`); - }) - core.setFailed('Found multiple projects with the similar name. Cannot determine which one to use.'); - return; - } - - const { id: projectId, fields: { nodes: fields } } = projects[0]; - const field = fields.find((field) => field.name === process.env.FIELD_NAME); - - if (!field) { - core.setFailed(`Field with name "${ process.env.FIELD_NAME }" not found in the project.`); - return; - } - - const option = field.options.find((option) => option.name === process.env.FIELD_VALUE); - - if (!option) { - core.setFailed(`Option with name "${ process.env.FIELD_VALUE }" not found in the field possible values.`); - return; - } - - core.info('Found following info:'); - core.info(` project_id: ${ projectId }`); - core.info(` field_id: ${ field.id }`); - core.info(` field_value_id: ${ option.id }`); - - core.setOutput('id', projectId); - core.setOutput('field_id', field.id); - core.setOutput('field_value_id', option.id); - - - name: Getting project items that linked to the issues - id: items - uses: actions/github-script@v7 - env: - ISSUES: ${{ inputs.issues }} - with: - github-token: ${{ secrets.BOT_LABEL_ISSUE_TOKEN }} - script: | - const result = []; - const issues = JSON.parse(process.env.ISSUES); - - for (const issue of issues) { - const response = await getProjectItemId(issue); - response?.length > 0 && result.push(...response); - } - - return result; - - async function getProjectItemId(issueId) { - core.info(`Fetching project items for issue #${ issueId }...`); - - try { - const response = await github.graphql(` - query ($owner: String!, $repo: String!, $id: Int!) { - repository(owner: $owner, name: $repo) { - issue(number: $id) { - title, - projectItems(first: 10) { - nodes { - id, - } - } - } - } - } - `, - { - owner: context.repo.owner, - repo: context.repo.repo, - id: issueId, - } - ); - - const { repository: { issue: { projectItems: { nodes: projectItems } } } } = response; - - if (projectItems.length === 0) { - core.info('No project items found.\n'); - return []; - } - - const ids = projectItems.map((item) => item.id); - core.info(`Found [ ${ ids.join(', ') } ].\n`); - return ids; - - } catch (error) { - if (error.status === 404) { - core.info('Nothing has found.\n'); - } - core.info(`Error: ${ error.message }\n`); - return []; - } - } - - - name: Updating field value of the project items - id: updating_items - uses: actions/github-script@v7 - env: - ITEMS: ${{ steps.items.outputs.result }} - PROJECT_ID: ${{ steps.project_info.outputs.id }} - FIELD_ID: ${{ steps.project_info.outputs.field_id }} - FIELD_VALUE_ID: ${{ steps.project_info.outputs.field_value_id }} - with: - github-token: ${{ secrets.BOT_LABEL_ISSUE_TOKEN }} - script: | - const items = JSON.parse(process.env.ITEMS); - - if (items.length === 0) { - core.info('Nothing to update.'); - core.notice('No project items found for provided issues. Nothing to update.'); - return; - } - - for (const item of items) { - core.info(`Changing field value for item ${ item }...`); - try { - await changeItemFieldValue(item); - core.info('Done.\n'); - } catch (error) { - core.info(`Error: ${ error.message }\n`); - } - } - - async function changeItemFieldValue(itemId) { - return await github.graphql( - ` - mutation($input: UpdateProjectV2ItemFieldValueInput!) { - updateProjectV2ItemFieldValue(input: $input) { - clientMutationId - } - } - `, - { - input: { - projectId: process.env.PROJECT_ID, - fieldId: process.env.FIELD_ID, - itemId, - value: { - singleSelectOptionId: process.env.FIELD_VALUE_ID, - }, - }, - } - ); - }; - From b8584574f9842e107e715b9e9e00178049308ae8 Mon Sep 17 00:00:00 2001 From: JOY <5027251+JOY@users.noreply.github.com> Date: Mon, 3 Aug 2026 21:25:46 +0700 Subject: [PATCH 2/2] ci: remove obsolete upstream label workflow --- .github/workflows/copy-issues-labels.yml | 122 ----------------------- 1 file changed, 122 deletions(-) delete mode 100644 .github/workflows/copy-issues-labels.yml diff --git a/.github/workflows/copy-issues-labels.yml b/.github/workflows/copy-issues-labels.yml deleted file mode 100644 index e9268737fe..0000000000 --- a/.github/workflows/copy-issues-labels.yml +++ /dev/null @@ -1,122 +0,0 @@ -name: Copy issues labels to pull request - -on: - workflow_dispatch: - inputs: - pr_number: - description: Pull request number - required: true - type: string - issues: - description: JSON encoded list of issue ids - required: true - type: string - workflow_call: - inputs: - pr_number: - description: Pull request number - required: true - type: string - issues: - description: JSON encoded list of issue ids - required: true - type: string - -permissions: - issues: read - pull-requests: write - -jobs: - run: - name: Run - runs-on: ubuntu-latest - steps: - - name: Find unique labels - id: find_unique_labels - uses: actions/github-script@v7 - env: - ISSUES: ${{ inputs.issues }} - with: - script: | - const issues = JSON.parse(process.env.ISSUES); - - const WHITE_LISTED_LABELS = [ - 'client feature', - 'feature', - 'breaking changes', - - 'bug', - - 'dependencies', - 'performance', - 'design', - - 'chore', - 'enhancement', - 'refactoring', - 'tech', - 'ENVs', - ] - - const labels = await Promise.all(issues.map(getIssueLabels)); - const uniqueLabels = uniqueStringArray(labels.flat().filter((label) => WHITE_LISTED_LABELS.includes(label))); - - if (uniqueLabels.length === 0) { - core.info('No labels found.\n'); - return []; - } - - core.info(`Found following labels: ${ uniqueLabels.join(', ') }.\n`); - return uniqueLabels; - - async function getIssueLabels(issue) { - core.info(`Obtaining labels list for the issue #${ issue }...`); - - try { - const response = await github.request('GET /repos/{owner}/{repo}/issues/{issue_number}/labels', { - owner: 'blockscout', - repo: 'frontend', - issue_number: issue, - }); - return response.data.map(({ name }) => name); - } catch (error) { - core.error(`Failed to obtain labels for the issue #${ issue }: ${ error.message }`); - return []; - } - } - - function uniqueStringArray(array) { - return Array.from(new Set(array)); - } - - - name: Update pull request labels - id: update_pr_labels - uses: actions/github-script@v7 - env: - LABELS: ${{ steps.find_unique_labels.outputs.result }} - PR_NUMBER: ${{ inputs.pr_number }} - with: - script: | - const labels = JSON.parse(process.env.LABELS); - const prNumber = Number(process.env.PR_NUMBER); - - if (labels.length === 0) { - core.info('Nothing to update.\n'); - return; - } - - for (const label of labels) { - await addLabelToPr(prNumber, label); - } - core.info('Done.\n'); - - async function addLabelToPr(prNumber, label) { - console.log(`Adding label to the pull request #${ prNumber }...`); - - return await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { - owner: 'blockscout', - repo: 'frontend', - issue_number: prNumber, - labels: [ label ], - }); - } \ No newline at end of file