Skip to content

Add workflow to rebuild dist/ on Dependabot PRs#118

Closed
gorkem wants to merge 1 commit intokitops-ml:mainfrom
gorkem:dependabot-rebuild-dist
Closed

Add workflow to rebuild dist/ on Dependabot PRs#118
gorkem wants to merge 1 commit intokitops-ml:mainfrom
gorkem:dependabot-rebuild-dist

Conversation

@gorkem
Copy link
Copy Markdown
Member

@gorkem gorkem commented Mar 28, 2026

What changed

Adds a new GitHub Actions workflow (dependabot-rebuild-dist.yml) that automatically rebuilds the checked-in dist/ directory when Dependabot opens a PR.

Why

Dependabot updates package.json/package-lock.json but doesn't run npm run bundle, so the check-dist CI job always fails on Dependabot PRs. This workflow detects Dependabot PRs, rebuilds dist/, and pushes the result back to the PR branch.

Uses the existing KitOps bot GitHub App token so the push triggers subsequent CI workflow runs.

Validation

  • Reviewed workflow YAML for correctness
  • Verified action pin SHAs match those used in existing workflows (check-dist.yml)
  • Scoped to github.actor == 'dependabot[bot]' only — no effect on human PRs

Dependabot doesn't rebuild the checked-in dist/ after updating
dependencies, causing the check-dist CI job to fail. This workflow
auto-rebuilds and pushes using a GitHub App token.

Signed-off-by: Gorkem Ercan <gorkem.ercan@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automation to keep the checked-in dist/ output in sync on Dependabot PRs so the existing “Check Transpiled JavaScript” CI job doesn’t fail due to stale bundled artifacts.

Changes:

  • Introduces a new workflow that runs on Dependabot PRs targeting main.
  • Uses a GitHub App token to rebuild dist/ and push the updated artifacts back to the PR branch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +13
on:
pull_request:
branches:
- main

Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is triggered on pull_request, but it relies on secrets.KITOPS_BOT_PRIVATE_KEY to mint a GitHub App token. For Dependabot PRs, repository secrets are typically not provided to pull_request-triggered workflows, so the token generation step will fail and the workflow won’t be able to push dist/. Switch the trigger to pull_request_target (still gated to Dependabot) so secrets are available, and ensure the checkout explicitly targets the PR head (e.g., PR head SHA/ref) before building/pushing.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@amisevsk amisevsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's comment is worth following up on, I'm not sure how secret propagation works.

I'm a little concerned about pulling in secrets on PR workflows, as a PR could potentially lead to leaking the token.

jobs:
rebuild-dist:
name: Rebuild dist/
if: github.actor == 'dependabot[bot]'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure this check is enough to stop this workflow running when a regular use pushes? I would worry about incidentally exposing the secret token.

@gorkem
Copy link
Copy Markdown
Member Author

gorkem commented Apr 16, 2026

I am closing this since the secret management is not making this a good solution

@gorkem gorkem closed this Apr 16, 2026
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.

3 participants