actions / actions/toolkit

Allow custom html attributes in `addTable` function

Open
#1,146 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
Please add ability to set custom HTML attributes
https://github.com/actions/toolkit/blob/main/packages/core/src/summary.ts#L229

Current code

await core.summary
    .addHeading("My Header")
    .addTable([
      [
        {data: 'Status', header: true},
        {data: 'Total', header: true},
        {data: 'Critical', header: true},
        {data: 'High', header: true},
        {data: 'Medium', header: true},
        {data: 'Low', header: true},
      ],
      [
        findings.status,
        findings.total?.toString()!,
        findings.critical?.toString()!,
        findings.high?.toString()!,
        findings.medium?.toString()!,
        findings.low?.toString()!,
      ]
    ])
    .write()

Current summary table format

<h1>My header</h1>
<table><tr><th>Status</th><th>Total</th><th>Critical</th><th>High</th><th>Medium</th><th>Low</th></tr><tr><td>COMPLETE</td><td>13</td><td>2</td><td>5</td><td>5</td><td>1</td></tr></table>

Desired code

await core.summary
    .addHeading("My Header")
    .addTable([
      [
        {data: 'Status', header: true},
        {data: 'Total', header: true},
        {data: 'Critical', header: true},
        {data: 'High', header: true},
        {data: 'Medium', header: true},
        {data: 'Low', header: true},
      ],
      [
        findings.status,
        { 
            data: findings.total?.toString()!, 
            attributes: {
               "fgcolor": "red
            }
        },
        findings.critical?.toString()!,
        findings.high?.toString()!,
        findings.medium?.toString()!,
        findings.low?.toString()!,
      ]
    ])
    .write()

Desired summary table format

<h1>My header</h1>
<table><tr><th>Status</th><th>Total</th><th>Critical</th><th>High</th><th>Medium</th><th>Low</th></tr><tr><td fgcolor="blue">COMPLETE</td><td fgcolor="red">13</td><td>2</td><td>5</td><td>5</td><td>1</td></tr></table>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at packages/core/src/summary.ts around the addTable function referenced in the issue, and trace how table cells become HTML. Add support for the requested cell attributes and verify that generated table-cell markup matches the desired HTML while existing cells remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.