From dfd9dd3d5add019cb00d9ce6fa1d68ada71debd5 Mon Sep 17 00:00:00 2001 From: Bogdan Popa Date: Wed, 17 Nov 2021 09:30:04 +0200 Subject: [PATCH] ci: bring back shouldUpdate check --- .github/actions/update-badge/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/actions/update-badge/index.js b/.github/actions/update-badge/index.js index 679615d1..7efc92ef 100644 --- a/.github/actions/update-badge/index.js +++ b/.github/actions/update-badge/index.js @@ -20,8 +20,12 @@ let octokit await core.group('Fetching repositories & updating lines...', async () => { for (const repo of repos) { const line = await generateLine(repo.repoStr) - core.info(`...repo line: '${line}'`) - lines[repo.index] = line + if (shouldUpdate(lines[repo.index], line)) { + lines[repo.index] = line + core.info(`...updated line: '${line}'`) + } else { + core.info(`...skipped line: '${line}'`) + } } }) @@ -75,3 +79,8 @@ async function generateBadge(repoStr) { .map(s => encodeURIComponent(s.replace(/\-/g, '--'))) .join('-') } + +function shouldUpdate(oldLine, newLine) { + const badDateReg = /red\)$/ + return badDateReg.test(oldLine) || !badDateReg.test(newLine) +}