ericcornelissen/svgo-action

Could not get GitHub client

Closed this issue ยท 8 comments

Bug Report

  • SVGO Action version: v2.1.5
  • On: push

Description

Action failing with error about "Could not get GitHub client" and "Could not initialize file filters"

Actual Behaviour

Action failed with teh following

| Running SVGO Action in 'push' context
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Initializing GitHub client
[Optimize SVG Files/SVGs]   โ—  ::error::Could not get GitHub client
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Initializing FileSystem to read SVGO config
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Reading the SVGO config file at svgo.config.js
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Parsing SVGO configuration
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Initializing SVGO
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Initializing optimization filters
[Optimize SVG Files/SVGs]   โ—  ::error::Could not initialize file filters
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Initializing FileSystem to read SVGs
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Optimizing SVGs
[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::Setting outputs
| 

yaml

name: Optimize SVG Files
on:
  pull_request:

  push:
    branches: [ master ]

jobs:
  svgs:
    name: SVGs
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3.0.0
    - uses: ericcornelissen/svgo-action@v2.1.5
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}

Expected Behaviour

Action to complete

Working Example

I rolled back to an older version and got the following. Unsure if it is relevant

[Optimize SVG Files/SVGs]   ๐Ÿ’ฌ  ::debug::missing repo-token
[Optimize SVG Files/SVGs]   โ—  ::error::Could not get GitHub client
[Optimize SVG Files/SVGs]   โŒ  Failure - ericcornelissen/svgo-action@v2.1.0

Thank you for the bug report @dgibbs64. Unfortunately I'm unable to reproduce this with the provided information. A couple of questions:

  • Do you use a custom Actions runner? (the logs you shared look different from what I'm used to, which is why I'm asking.)
  • Can you share the repository where this is happening?
    • If yes, please also share a link to the logs of a failing run.
    • If not, creating a minimum project that reproduces the bug that you can share would be extremely useful.
  • Are you using ${{ secrets.GITHUB_TOKEN }} successfully somewhere in this or a different workflow for the same repository?

I rolled back to an older version and got the following.

Do you recall which version exactly?

Hello,

I was using ACT to test the action and I get the same result on the repo
This is the repo
https://github.com/linuxserver/Heimdall-Apps
and here is an example of the failure
https://github.com/linuxserver/Heimdall-Apps/actions/runs/2012438925
Yes, secrets.GITHUB_TOKEN is being used successfully in another workflow

I believe it was a version 2.1.2 that I used. I kept going back version at a time to see if there was a difference. I noticed older versions seemed to give a little more feedback of the error.

Thank you for your help ๐Ÿ˜ƒ

I get the same result on the repo
This is the repo
https://github.com/linuxserver/Heimdall-Apps
and here is an example of the failure
https://github.com/linuxserver/Heimdall-Apps/actions/runs/2012438925
Yes, secrets.GITHUB_TOKEN is being used successfully in another workflow

I'm not seeing any failed runs of the Optimize SVG Files workflow (list of all runs for reference). And of the five-or-so runs that I looked at, none are showing any errors in the logs.

Have you seen the error you shared earlier in this repository as well?1

Also, what are you trying to achieve with the workflow? If you're trying to automatically optimize the SVGs in the repository, the workflow you're currently using is insufficient. Please refer to the examples for examples of how to achieve that.

I was using ACT to test the action

I have actually never tested this Action with ACT (as I've never used ACT before). Is it important for you that SVGO-Action works with ACT as well?

I believe it was a version 2.1.2 that I used. I kept going back version at a time to see if there was a difference. I noticed older versions seemed to give a little more feedback of the error.

Thanks for clarifying ๐Ÿ™‚

Footnotes

  1. It might be that I can't see debug logs of the repository because I'm not a member, I'm not sure of that. Though, even so, I should still be able to see that a run failed, which is what should happen in case of the error you shared. โ†ฉ

@dgibbs64 I see you reacted with a โค๏ธ Did you manage to solve your problem based on my previous comment?

Hi @ericcornelissen sadly it is still not working. My current guess is that the action is not finding the SVG files. I updated the action as per your examples but I get no feedback from the action as to what the actual problem is. Any advise on why it might not be finding avg files would be great. Thank you

https://github.com/linuxserver/Heimdall-Apps/tree/master/.github/workflows

image

@dgibbs64 when the Action is triggered on: push it will only optimize SVGs that were changed in the commits being pushed. My guess is that's why it's not optimizing any SVGs for the run in the screenshot you shared.

The reason for this behaviour is to prevent making a large amount of changes unexpectedly when the Action is introduced to an existing project. If you do want to optimize all existing SVGs I'd recommend either:

  1. Manually triggering an optimization once (note: this can also be triggered through the UI, that details seems to be missing from the docs1), or
  2. Scheduling optimization, or
  3. Running SVGO locally and committing the result before you start using this Action.

Footnotes

  1. Created https://github.com/ericcornelissen/svgo-action/issues/543 to work on improving the documentation โ†ฉ

thanks for your help :)