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

feat: Enable "renovate changeset" action to work with dependabot #153

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions renovate-changesets/action.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
name: Backstage Renovate Changeset Creator
description: Create changesets on the renovate bot PR's if needed
name: Backstage Dependency Manager Changeset Creator
Copy link
Member

Choose a reason for hiding this comment

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

The action is still named renovate-changesets though.

Hm. Should we make a new parallel one that has this new ability (and is named dependency-manager-changesets)? Possibly deprecating the existing one later down the line in a separate PR.

Alternatively: Should we instead make a new parallel one specifically named dependabot-changesets and leave the old one intact?

Copy link
Author

Choose a reason for hiding this comment

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

The former would require some upstream changes.
The latter would probably create more duplicated code (or the need to share code)

description: Create changesets on the dependency manager bot PR's if needed
inputs:
multiple-workspaces:
description: If it's this repository is a collection of workspaces
required: false
default: 'false'
dependency-manager:
description: The dependency manager to use
required: false
default: 'renovate'

outputs: {}
runs:
Expand Down
10 changes: 10 additions & 0 deletions renovate-changesets/dependencyConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as core from '@actions/core';

export const getDependencyManager = (): string => {
return core
.getInput('dependency-manager', {
required: false,
Copy link
Member

Choose a reason for hiding this comment

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

It's set with a default in the yaml file. But still marked as not required here? What's even the return type here, can .trim below get an undefined error if the default wasn't there? See the comment above; maybe it's better to just make two actions that are specialized, or change around how this works a bit

})
.trim()
.toLowerCase();
};
9 changes: 5 additions & 4 deletions renovate-changesets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import {
getChangedFiles,
getChangesetFilename,
listPackages,
} from './renovateChangesets';
} from './manageChangesets';
import { relative as relativePath, resolve as resolvePath } from 'path';
import { getDependencyManager } from './dependencyConfig';

async function main() {
core.info('Running Renovate Changesets');
core.info(`Running ${getDependencyManager()} Changesets`);

const isMultipleWorkspaces = core.getBooleanInput('multiple-workspaces', {
required: false,
});

const branchName = await getBranchName();

if (!branchName.startsWith('renovate/')) {
core.info('Not a renovate branch, skipping');
if (!branchName.startsWith(getDependencyManager())) {
Copy link
Member

Choose a reason for hiding this comment

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

forgot the slash here

core.info(`Not a ${getDependencyManager()} branch, skipping`);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getExecOutput, exec } from '@actions/exec';
import fs from 'fs/promises';
import { resolve as resolvePath, relative as relativePath } from 'path';
import { getPackages, type Package } from '@manypkg/get-packages';
import { getDependencyManager } from './dependencyConfig';

export async function getBranchName() {
const { stdout } = await getExecOutput('git', ['branch', '--show-current']);
Expand Down Expand Up @@ -34,7 +35,7 @@ export async function getChangesetFilename() {
const { stdout: shortHash } = await getExecOutput(
'git rev-parse --short HEAD',
);
return `.changeset/renovate-${shortHash.trim()}.md`;
return `.changeset/${getDependencyManager()}-${shortHash.trim()}.md`;
}

export async function createChangeset(
Expand Down
Loading