Skip to content

Commit

Permalink
fix(manager/github-actions): preserve full depName
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Jan 7, 2025
1 parent 37c05dc commit dd0097c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/modules/manager/github-actions/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ describe('modules/manager/github-actions/extract', () => {
build:
steps:
- name: "test1"
uses: https://github.com/actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # tag=v3.1.1
uses: https://github.com/actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # tag=v4.2.0
- name: "test2"
uses: https://code.forgejo.org/actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # v3.1.1
- name: "test3"
Expand All @@ -479,14 +479,18 @@ describe('modules/manager/github-actions/extract', () => {
expect(res).toMatchObject({
deps: [
{
currentDigest: '56337c425554a6be30cdef71bf441f15be286854',
currentValue: 'v3.1.1',
depName: 'https://github.com/actions/cache',
packageName: 'actions/cache',
currentDigest: '1bd1e32a3bdc45362d1e726936510720a7c30a57',
currentValue: 'v4.2.0',
replaceString:
'https://github.com/actions/setup-node@56337c425554a6be30cdef71bf441f15be286854 # tag=v3.1.1',
'https://github.com/actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # tag=v4.2.0',
datasource: 'github-tags',
registryUrls: ['https://github.com/'],
},
{
depName: 'https://code.forgejo.org/actions/setup-node',
packageName: 'actions/setup-node',
currentDigest: '56337c425554a6be30cdef71bf441f15be286854',
currentValue: 'v3.1.1',
replaceString:
Expand Down
6 changes: 4 additions & 2 deletions lib/modules/manager/github-actions/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { Workflow } from './types';

const dockerActionRe = regEx(/^\s+uses\s*: ['"]?docker:\/\/([^'"]+)\s*$/);
const actionRe = regEx(
/^\s+-?\s+?uses\s*: (?<replaceString>['"]?(?<registryUrl>https:\/\/[.\w-]+\/)?(?<depName>[\w-]+\/[.\w-]+)(?<path>\/.*)?@(?<currentValue>[^\s'"]+)['"]?(?:(?<commentWhiteSpaces>\s+)#\s*(((?:renovate\s*:\s*)?(?:pin\s+|tag\s*=\s*)?|(?:ratchet:[\w-]+\/[.\w-]+)?)@?(?<tag>([\w-]*-)?v?\d+(?:\.\d+(?:\.\d+)?)?)|(?:ratchet:exclude)))?)/,
/^\s+-?\s+?uses\s*: (?<replaceString>['"]?(?<depName>(?<registryUrl>https:\/\/[.\w-]+\/)?(?<packageName>[\w-]+\/[.\w-]+))(?<path>\/.*)?@(?<currentValue>[^\s'"]+)['"]?(?:(?<commentWhiteSpaces>\s+)#\s*(((?:renovate\s*:\s*)?(?:pin\s+|tag\s*=\s*)?|(?:ratchet:[\w-]+\/[.\w-]+)?)@?(?<tag>([\w-]*-)?v?\d+(?:\.\d+(?:\.\d+)?)?)|(?:ratchet:exclude)))?)/,
);

// SHA1 or SHA256, see https://github.blog/2020-10-19-git-2-29-released/
Expand Down Expand Up @@ -74,6 +74,7 @@ function extractWithRegex(
if (tagMatch?.groups) {
const {
depName,
packageName,
currentValue,
path = '',
tag,
Expand All @@ -90,12 +91,13 @@ function extractWithRegex(
}
const dep: PackageDependency = {
depName,
...(packageName !== depName && { packageName }),
commitMessageTopic: '{{{depName}}} action',
datasource: GithubTagsDatasource.id,
versioning: dockerVersioning.id,
depType: 'action',
replaceString,
autoReplaceStringTemplate: `${quotes}${registryUrl}{{depName}}${path}@{{#if newDigest}}{{newDigest}}${quotes}{{#if newValue}}${commentWhiteSpaces}# {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}${quotes}{{/unless}}`,
autoReplaceStringTemplate: `${quotes}{{depName}}${path}@{{#if newDigest}}{{newDigest}}${quotes}{{#if newValue}}${commentWhiteSpaces}# {{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}${quotes}{{/unless}}`,
...(registryUrl
? detectDatasource(registryUrl)
: customRegistryUrlsPackageDependency),
Expand Down

0 comments on commit dd0097c

Please sign in to comment.