derberg / manage-files-in-multiple-repositories

GitHub Action that introduces support for global workflows. Global workflows are the one you update in just one repo and they are automatically updated in other repositories.
MIT License
52 stars 18 forks source link

Error: Action failed because of: TypeError: Cannot destructure property `name` of 'undefined' or 'null'. #1

Closed felixk closed 3 years ago

felixk commented 3 years ago

Thanks for this code...

I tried to set this up, and I get this error message when I run the action on my .github repo:

Error: Action failed because of: TypeError: Cannot destructure property `name` of 'undefined' or 'null'.

This happens right after this message: Getting list of repositories owned by NuBanko that will get updates. The following repos will be later ignored: [my ignored repos],.github

Any ideas what could be wrong. My workflow file looks like this:

name: Global workflow Update

on:
  push:
      branches: [ master ] #or main

jobs:

  replicate_changes:

      runs-on: ubuntu-latest

      steps:
        - name: Checkout repository
          uses: actions/checkout@v2
        - name: Replicating global workflow
          uses: derberg/global-workflows-support@v0.0.2
          with:
            github_token: ${{ secrets.CUSTOM_TOKEN }}
            files_to_ignore: globalworkflows.yml
            repos_to_ignore: [list comma delimted]
            committer_username: [my username]
            committer_email: [my email]
            commit_message: "ci: update global workflows"
derberg commented 3 years ago

Hey @felixk,

If you do not have any specific data to provide here:

            repos_to_ignore: [list comma delimted]
            committer_username: [my username]
            committer_email: [my email]

then just omit those options, just remove them from the file.

regarding the error itself, it is related to this line. This means reposList is undefined, which leads me to the question, are you sure CUSTOM_TOKEN is provided in your secrets?

felixk commented 3 years ago

Hey thanks for the quick response.

I recreated a personal token with all the possible permissions. Set my CUSTOM_TOKEN repo secret and still getting that error.

Any other ideas why the GitHub Api is failing?

Thanks!

derberg commented 3 years ago

Gimme few hours, I'll add some debug logs and release another version so you can checkout and grab more info from the logs

felixk commented 3 years ago

Okay thanks! As a quick test I used your project and wrote the following, and it returned my repolist:

async function run() {
    const gitHubKey = "MY CUSTOM_TOKEN WENT HERE";

    const octokit = github.getOctokit(gitHubKey);
    const reposList = await getReposList(octokit, "myorg");
    console.log(reposList);
}
derberg commented 3 years ago

@felixk new version v0.0.3 is out. Check it out. To enable debug do what is written here https://github.com/derberg/global-workflows-support#debug

please later paste all logs here so I can have a look

derberg commented 3 years ago

@felixk any luck?

felixk commented 3 years ago

I'm really sorry I didn't have a chance to try this. I was in a rush to get something implemented and ended up using your code to create a very simplified version of your action: workflow-updater-action

I'll give your changes a try in the next few days and try to see what was wrong.

derberg commented 3 years ago

@felixk did you have a chance to check it? not sure if I should keep it open

derberg commented 3 years ago

@felixk I'm gonna close. Anyway I think I know what issue you had as I had similar in my organization. I just released a fix. The issue was that the GitHub API could not provide default branch info for one repo and restructuring failed, why? cause one repo was not initialized and not initialized repos do not have default branches