Skip to content
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

chore: add dependabot-sync action #191

Merged
merged 4 commits into from
Feb 12, 2025
Merged

Conversation

andreynering
Copy link
Member

Similar to the existing lint-sync, this will be references on our repos and make it easier to manage Dependabot config from now on.

Comment on lines +30 to +41
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "05:00"
timezone: "America/New_York"
labels:
- "dependencies"
commit-message:
prefix: "feat"
include: "scope"
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed some repositories that do not have a Dockerfile included a config to keep Docker up-to-date (the file was probably just copy-and-pasted at the time). This means that this is a no-op action if a Dockerfile is not available.

I decided to use it in our favor and have it by default, even if many repos do not have Dockerfiles. This allows us to have less specific config files as the base work for more repos.

Copy link
Member

@aymanbagabas aymanbagabas left a comment

Choose a reason for hiding this comment

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

I would just keep one dependabot.yml file and consolidate all of them, wdyt @andreynering ?

@andreynering
Copy link
Member Author

@aymanbagabas Some repos really have different rules. For example, an additional examples/ or spinner/ dir. The two GitHub Action repos have npm config, etc. Although the Docker setting was no-op, I'm not sure about others; they may break the CI if the dir doesn't exist.

@andreynering
Copy link
Member Author

Another thing... the x repo have an script to generate a config for each package: https://github.com/charmbracelet/x/blob/main/scripts/dependabot. Should we keep that one as is or try to integrate here on meta somehow? /cc @aymanbagabas @caarlos0

@andreynering andreynering force-pushed the add-dependabot-sync-action branch from 59c77dd to 0f0c579 Compare February 12, 2025 16:55
Comment on lines 23 to 26
DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot-${{ github.event.repository.name }}.yml"
if [ ! -f $DEPENDABOT_FILE ]; then
DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot.yml"
fi
Copy link
Member

Choose a reason for hiding this comment

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

To keep files short and concise, we can have the repository specific settings stored in dependabot-repo.yml, then they get concatenated here. wdyt?

Suggested change
DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot-${{ github.event.repository.name }}.yml"
if [ ! -f $DEPENDABOT_FILE ]; then
DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot.yml"
fi
cat "${{ github.repository_owner }}/meta/dependabot/dependabot.yml" > "${{ github.repository }}/dependabot.yml"
DEPENDABOT_FILE="${{ github.repository_owner }}/meta/dependabot/dependabot-${{ github.event.repository.name }}.yml"
if [ -f "$DEPENDABOT_FILE" ]; then
cat "$DEPENDABOT_FILE" >> "${{ github.repository }}/dependabot.yml"
fi

Copy link
Member Author

Choose a reason for hiding this comment

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

There would be at least three exceptions. These repos don't have any Go code, so they have config for GHA and/or npm only.

  • dependabot/dependabot-nur.yml
  • dependabot/dependabot-vhs-action.yml
  • dependabot/dependabot-soft-serve-action.yml

Copy link
Member

Choose a reason for hiding this comment

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

Sure, in that case, since they don't have a go.mod file, dependabot will just skip that part, right? If so I think that's fine, especially if it will reduce the overhead and maintenance in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if the step will skip if go.mod is missing, but Okay, let's try that! We'll just need to adjust if it don't work as expected.

@aymanbagabas
Copy link
Member

Another thing... the x repo have an script to generate a config for each package: https://github.com/charmbracelet/x/blob/main/scripts/dependabot. Should we keep that one as is or try to integrate here on meta somehow? /cc @aymanbagabas @caarlos0

I'd say let's keep x as is since it's a special case

Copy link
Member

@aymanbagabas aymanbagabas left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -0,0 +1,45 @@
name: dependabot-sync
on:
workflow_call:
Copy link
Member

Choose a reason for hiding this comment

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

could use inputs here so the caller sets the filename, then we don't need that shell script

example:

Copy link
Member

Choose a reason for hiding this comment

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

It would be cool to be able to call this workflow from the GitHub webUI, specify a repo, and run the workflow for it to do the work, copy the config and open a PR in the given repo. Same goes for lint-sync

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. That got me the idea that this workflow could also copy the actual workflow file to the repo, so I don't have to open manual PRs for each repo. 🙂

@andreynering andreynering merged commit d5de784 into main Feb 12, 2025
4 checks passed
@andreynering andreynering deleted the add-dependabot-sync-action branch February 12, 2025 21:10
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