diff --git a/.github/actions/check-labels/index.js b/.github/actions/check-labels/index.js index d2e510b89..ba367c66c 100644 --- a/.github/actions/check-labels/index.js +++ b/.github/actions/check-labels/index.js @@ -19,6 +19,23 @@ async function run() { const hasMultipleSemverLabels = attachedSemverLabels.length > 1; const hasOneSemverLabel = attachedSemverLabels.length === 1; const hasReleaseLabel = labelNames.includes('release'); + const userName = pull_request.user.login; + + if (userName === 'renovate[bot]') { + if (isMissingSemverLabel) { + const files = await getPullRequestFiles({ octokit }); + + const isOnlyLockFileChanged = files.every((file) => file.filename.endsWith('package-lock.json')); + if (isOnlyLockFileChanged) { + console.log('Detected renovate PR with only lock file changes. Applying `no-changelog` label.'); + await updateLabels({ octokit, labels: ['no-changelog'] }); + } else { + console.log('Detected renovate PR with file changes. Applying `patch` label.'); + await updateLabels({ octokit, labels: ['patch'] }); + } + } + core.setOutput('canMerge', 'Renovate PR'); + } if (isMissingSemverLabel) { let errorMsg = [ @@ -91,6 +108,38 @@ async function run() { } } +async function getPullRequestFiles({ octokit }) { + const { + payload: { pull_request }, + repo, + } = context; + const prNumber = pull_request.number; + const { data } = await octokit.rest.pulls.listFiles({ + ...repo, + pull_number: prNumber, + }); + + return data; +} + +async function updateLabels({ octokit, labels }) { + try { + const { + payload: { pull_request }, + repo, + } = context; + const prNumber = pull_request.number; + + await octokit.rest.issues.setLabels({ + ...repo, + issue_number: prNumber, + labels, + }); + } catch (error) { + core.setFailed(error.message); + } +} + async function doComment({ octokit, message }) { try { const { diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 7f66e6b81..59a632e6e 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -6,7 +6,7 @@ "reviewers": ["team:grafana/plugins-platform-frontend"], "enabledManagers": ["regex", "npm", "github-actions"], "postUpdateOptions": ["npmDedupe"], - "labels": ["dependencies", "javascript", "patch"], + "labels": ["dependencies", "javascript"], // These custom managers are used to bump dependencies in create-plugin template files "customManagers": [ { diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml index 9e0e00ca3..3cee92990 100644 --- a/.github/workflows/check-labels.yml +++ b/.github/workflows/check-labels.yml @@ -10,7 +10,6 @@ on: - edited concurrency: group: ${{ github.workflow }}-${{ github.event.number }} - cancel-in-progress: true permissions: pull-requests: write