Skip to content

Generate licenses.json via GitHub Actions after dependency updates (#38) #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

mattfsourcecode
Copy link
Owner

@mattfsourcecode mattfsourcecode commented Feb 2, 2025

Summary of Changes:

  1. Adds a workflow to generate licenses.json

    • Implements a new GitHub Actions workflow using license-checker to automatically generate a licenses.json file whenever package.json or pnpm-lock.yaml changes. The licenses.json file contains license information for each dependency, along with details such as the repository URL, publisher, and other metadata provided by the package authors.
  2. Configures PERSONAL_ACCESS_TOKEN for secure commits

    • Adds a repository secret named PERSONAL_ACCESS_TOKEN to authorize GitHub Actions (github-actions[bot]) to commit changes directly. This ensures license updates are committed securely and automatically.
  3. Updates test-and-build workflow trigger

    • Previous:
      on:
        pull_request:
          branches:
            - master
    • Updated:
      on:
        push:
          branches:
            - "**"
        pull_request:
          branches:
            - "**"
    • This change ensures that the test-and-build workflow runs on both push and pull_request events across all branches ("**"). It guarantees the check will trigger after the license file is committed, making it the final validation step before merging.
  4. Bumps dependency version

    • Updated the following dependency:
      - "@types/node": "^22.12.0",
      + "@types/node": "^22.13.0",
    • This version bump had not yet been handled by Dependabot.

⚠️ Note Regarding Dependabot:

  • Potential concern: This PR doesn’t allow us to verify if github-actions[bot] can still automatically merge pull requests when github-actions[bot] is the last contributor. The current configuration might require the last commit to be made by Dependabot.

  • Why it’s expected to work:

    • The automation uses github-actions[bot] with PERSONAL_ACCESS_TOKEN, which should meet the required permissions.
    • The test-and-build workflow now runs after commits from GitHub Actions, satisfying branch protection rules.

We will be able to confirm this functionality fully when the next Dependabot PR invokes an automatic merge.


Closes #38

@mattfsourcecode mattfsourcecode force-pushed the generate-license-json-via-github-actions-after-dependency-updates branch from f096f7c to e48960e Compare February 2, 2025 15:23
@mattfsourcecode mattfsourcecode marked this pull request as ready for review February 2, 2025 15:29
@mattfsourcecode mattfsourcecode force-pushed the generate-license-json-via-github-actions-after-dependency-updates branch from 66f831c to 753c11a Compare February 2, 2025 15:33
@mattfsourcecode mattfsourcecode marked this pull request as draft February 2, 2025 15:34
@mattfsourcecode mattfsourcecode changed the title Generate license.json via GitHub Actions after deps updates (#38) Generate licenses.json with GitHub Actions after dependency updates (#38) Feb 2, 2025
@mattfsourcecode mattfsourcecode force-pushed the generate-license-json-via-github-actions-after-dependency-updates branch 25 times, most recently from 3b826a4 to e9675d2 Compare February 2, 2025 20:02
@mattfsourcecode mattfsourcecode force-pushed the generate-license-json-via-github-actions-after-dependency-updates branch from 7861f9c to 7682cd0 Compare February 2, 2025 20:03
@mattfsourcecode mattfsourcecode marked this pull request as ready for review February 2, 2025 20:12
@mattfsourcecode mattfsourcecode changed the title Generate licenses.json with GitHub Actions after dependency updates (#38) Generate licenses.json via GitHub Actions after dependency updates (#38) Feb 2, 2025
@mattfsourcecode mattfsourcecode merged commit 5367795 into master Feb 2, 2025
5 checks passed
@mattfsourcecode mattfsourcecode deleted the generate-license-json-via-github-actions-after-dependency-updates branch February 2, 2025 20:48
@mattfsourcecode
Copy link
Owner Author

mattfsourcecode commented Feb 3, 2025

⚠️ Note Regarding Dependabot:

  • Potential concern: This PR doesn’t allow us to verify if github-actions[bot] can still automatically merge pull requests when github-actions[bot] is the last contributor. The current configuration might require the last commit to be made by Dependabot.

  • Why it’s expected to work:

    • The automation uses github-actions[bot] with PERSONAL_ACCESS_TOKEN, which should meet the required permissions.
    • The test-and-build workflow now runs after commits from GitHub Actions, satisfying branch protection rules.

We can fully confirm this functionality when the next Dependabot PR invokes an automatic merge.

Follow-up:

The license-checker package lists license information for subdependencies in the pnpm-lock.yaml when run locally. However, when run as part of the GitHub Action, it only lists license information for direct dependencies and devDependencies. This means changes made by Dependabot would likely have infrequent impacts on the license information. The check would be more valuable if subdependency licenses were also included.

New Issue Added: #46

@mattfsourcecode
Copy link
Owner Author

mattfsourcecode commented Feb 3, 2025

The check would be more valuable if subdependency licenses were also included.

Nonetheless, the added check automatically detects when developers add new dependencies and devDependencies, and updates the licenses.json file accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate a license.json file with license-checker via GitHub Actions after dependency updates
1 participant