From 2cf304b69ab1ca0022cab1e3c6261debb699b460 Mon Sep 17 00:00:00 2001 From: Philip <philipabed451@gmail.com> Date: Mon, 14 Feb 2022 12:39:23 +0200 Subject: [PATCH] fix(manager/github-actions): dependencies with quotes are ignored (#14130) --- .../github-actions/__fixtures__/workflow_3.yml | 9 +++++++++ .../__snapshots__/extract.spec.ts.snap | 15 +++++++++++++++ lib/manager/github-actions/extract.spec.ts | 13 +++++++++++++ lib/manager/github-actions/extract.ts | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 lib/manager/github-actions/__fixtures__/workflow_3.yml diff --git a/lib/manager/github-actions/__fixtures__/workflow_3.yml b/lib/manager/github-actions/__fixtures__/workflow_3.yml new file mode 100644 index 0000000000..781bec6781 --- /dev/null +++ b/lib/manager/github-actions/__fixtures__/workflow_3.yml @@ -0,0 +1,9 @@ +jobs: + automerge: + runs-on: ubuntu-latest + steps: + - name: Auto merge + uses: "pascalgn/automerge-action@v0.13.1" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + MERGE_METHOD: squash diff --git a/lib/manager/github-actions/__snapshots__/extract.spec.ts.snap b/lib/manager/github-actions/__snapshots__/extract.spec.ts.snap index 412c11f3e3..42abf7b049 100644 --- a/lib/manager/github-actions/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/github-actions/__snapshots__/extract.spec.ts.snap @@ -136,3 +136,18 @@ Array [ }, ] `; + +exports[`manager/github-actions/extract extractPackageFile() extracts tag line with double quotes 1`] = ` +Array [ + Object { + "autoReplaceStringTemplate": "{{depName}}@{{#if newDigest}}{{newDigest}}{{#if newValue}} # tag={{newValue}}{{/if}}{{/if}}{{#unless newDigest}}{{newValue}}{{/unless}}", + "commitMessageTopic": "{{{depName}}} action", + "currentValue": "v0.13.1", + "datasource": "github-tags", + "depName": "pascalgn/automerge-action", + "depType": "action", + "replaceString": "\\"pascalgn/automerge-action@v0.13.1\\"", + "versioning": "docker", + }, +] +`; diff --git a/lib/manager/github-actions/extract.spec.ts b/lib/manager/github-actions/extract.spec.ts index cf3ec22966..23a5511b34 100644 --- a/lib/manager/github-actions/extract.spec.ts +++ b/lib/manager/github-actions/extract.spec.ts @@ -18,5 +18,18 @@ describe('manager/github-actions/extract', () => { res.deps.filter((d) => d.datasource === 'github-tags') ).toHaveLength(8); }); + it('extracts tag line with double quotes', () => { + const res = extractPackageFile(Fixtures.get('workflow_3.yml')); + expect(res.deps).toMatchSnapshot([ + { + currentValue: 'v0.13.1', + datasource: 'github-tags', + depName: 'pascalgn/automerge-action', + depType: 'action', + replaceString: '"pascalgn/automerge-action@v0.13.1"', + versioning: 'docker', + }, + ]); + }); }); }); diff --git a/lib/manager/github-actions/extract.ts b/lib/manager/github-actions/extract.ts index c322c1cb5d..7e69c3416e 100644 --- a/lib/manager/github-actions/extract.ts +++ b/lib/manager/github-actions/extract.ts @@ -7,7 +7,7 @@ import type { PackageDependency, PackageFile } from '../types'; const dockerRe = regEx(/^\s+uses: docker:\/\/([^"]+)\s*$/); const actionRe = regEx( - /^\s+-?\s+?uses: (?<replaceString>(?<depName>[\w-]+\/[\w-]+)(?<path>\/.*)?@(?<currentValue>.+?)\s*(?:#\s+(?:renovate:\s+)?tag=(?<tag>.+?))?)\s*?$/ + /^\s+-?\s+?uses: (?<replaceString>['"]?(?<depName>[\w-]+\/[\w-]+)(?<path>\/.*)?@(?<currentValue>.+?)\s*['"]?(?:#\s+(?:renovate:\s+)?tag=(?<tag>.+?))?)\s*?$/ ); // SHA1 or SHA256, see https://github.blog/2020-10-19-git-2-29-released/ -- GitLab