JJ / github-pr-contains-action

Action that checks whether the body or diff in a PR contains a certain word.
MIT License
29 stars 33 forks source link

files env variable is too long #119

Closed v1v closed 5 months ago

v1v commented 5 months ago

https://github.com/JJ/github-pr-contains-action/blob/302a97797f4f1b10bbcddeb9916f39bc45a7c6e7/src/main.ts#L96 is the one that produces the below error

Error: An error occurred trying to start process '/usr/bin/bash' with working directory '/home/runner/work/catalog-info/catalog-info'. Argument list too long

When parsing 60 files

image
v1v commented 5 months ago

Given the GitHub workflow:

name: "downgrade detection"
on:
  pull_request_target:

jobs:
  check-pr:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - name: "Check PR content"
        id: "check-level"
        continue-on-error: true
        uses: JJ/github-pr-contains-action@releases/v12
        with:
          github-token: ${{github.token}}
          diffContains: 'level: test|level: low'
      - name: "Remove the label of the PR, if needed"
        if: steps.check-level.outcome == 'failure'
        run: gh pr edit $PR_NUMBER --remove-label "level:downgrade"
        env:
          GH_TOKEN: ${{ github.token }}
          PR_NUMBER: ${{ github.event.pull_request.number }}

When a PR is created and it contains a few dozens of new files:

resources/github/engineering/obs/agent-nodejs-opentracing.yaml
resources/github/engineering/obs/agent-python-benchmarks.yaml
resources/github/engineering/obs/aws-lambda.yaml
...
resources/github/engineering/obs/synthetics-service.yaml
resources/github/engineering/obs/synthetics.yaml

Then any steps after using uses: JJ/github-pr-contains-action@releases/v12 will fail with:

Run gh pr edit $PR_NUMBER --remove-label "level:downgrade"
  gh pr edit $PR_NUMBER --remove-label "level:downgrade"
  shell: /usr/bin/bash -e {0}
  env:
    files: [{"chunks":[{"content":"@@ -0,0 +1,32 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+---"},{"type":"add","add":true,"ln":2,"content":"+apiVersion: backstage.io/v1alpha1"},...{"type":"add","add":true,"ln":29,"content":"+        observability-leads:"},{"type":"add","add":true,"ln":30,"content":"+          role: Admin"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":30}],"deletions":0,"additions":30,"from":"/dev/null","to":"resources/github/engineering/obs/uptime.yaml","new":true,"index":["00000000..0026baf6"]}]
    GH_TOKEN: ***
    PR_NUMBER: ***
Error: An error occurred trying to start process '/usr/bin/bash' with working directory '/home/runner/work/catalog-info/catalog-info'. Argument list too long