Skip to content

Instantly share code, notes, and snippets.

@bastionkid
Last active June 16, 2023 06:11
Show Gist options
  • Select an option

  • Save bastionkid/3b41693456e908a04ae736690cbfb069 to your computer and use it in GitHub Desktop.

Select an option

Save bastionkid/3b41693456e908a04ae736690cbfb069 to your computer and use it in GitHub Desktop.

Revisions

  1. bastionkid revised this gist Jun 16, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions size_metrics.yml
    Original file line number Diff line number Diff line change
    @@ -24,10 +24,12 @@ jobs:
    runs-on: ubuntu-latest

    steps:
    # Step 1
    - uses: actions/download-artifact@v3
    with:
    name: ${{ env.size_diff_report_file }}

    # Step 2
    - name: Add PR Comment
    uses: actions/github-script@v6
    with:
  2. bastionkid created this gist Jun 16, 2023.
    51 changes: 51 additions & 0 deletions size_metrics.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    name: Size Metrics

    ...
    # content is omitted as it's already shown earlier
    ...

    env:
    size_diff_report_file: apk_size_diff_report.html

    jobs:
    build:
    ...
    # content is omitted as it's already shown earlier
    ...

    size_diff_report:
    ...
    # content is omitted as it's already shown earlier
    ...

    pr_comment:
    needs: size_diff_report
    name: PR Comment (Size Report)
    runs-on: ubuntu-latest

    steps:
    - uses: actions/download-artifact@v3
    with:
    name: ${{ env.size_diff_report_file }}

    - name: Add PR Comment
    uses: actions/github-script@v6
    with:
    script: |
    const fs = require('fs');
    try {
    const filePath = 'apk_size_diff_report.html'
    const sizeReportContent = fs.readFileSync(filePath, 'utf8')
    const result = await github.rest.issues.createComment({
    issue_number: context.issue.number,
    owner: context.repo.owner,
    repo: context.repo.repo,
    body: sizeReportContent
    })
    console.log(result)
    } catch (error) {
    console.error('Error reading file:', error);
    }