mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
chore: add reviewers automatically
This commit is contained in:
parent
c1f004ee9d
commit
a3eb000821
79
.github/workflows/detect-breaking-changes.yml
vendored
79
.github/workflows/detect-breaking-changes.yml
vendored
@ -39,6 +39,7 @@ jobs:
|
|||||||
return `https://github.com/grafana/grafana/runs/${result.data.jobs[0].id}?check_suite_focus=true`;
|
return `https://github.com/grafana/grafana/runs/${result.data.jobs[0].id}?check_suite_focus=true`;
|
||||||
|
|
||||||
- name: Detect breaking changes
|
- name: Detect breaking changes
|
||||||
|
id: breaking-changes
|
||||||
run: ./scripts/check-breaking-changes.sh
|
run: ./scripts/check-breaking-changes.sh
|
||||||
env:
|
env:
|
||||||
FORCE_COLOR: 3
|
FORCE_COLOR: 3
|
||||||
@ -49,7 +50,7 @@ jobs:
|
|||||||
id: finder
|
id: finder
|
||||||
|
|
||||||
- name: Comment on PR
|
- name: Comment on PR
|
||||||
if: ${{ env.BREAKING_CHANGES_IS_BREAKING == '1' || env.BREAKING_CHANGES_IS_BREAKING == 1 }}
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 1 }}
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
uses: marocchino/sticky-pull-request-comment@v2
|
||||||
with:
|
with:
|
||||||
number: ${{ steps.finder.outputs.pr }}
|
number: ${{ steps.finder.outputs.pr }}
|
||||||
@ -58,18 +59,36 @@ jobs:
|
|||||||
|
|
||||||
_(Open the links below in a new tab to go to the correct steps)_
|
_(Open the links below in a new tab to go to the correct steps)_
|
||||||
|
|
||||||
${{ env.BREAKING_CHANGES_MESSAGE }}
|
${{ steps.breaking-changes.outputs.message }}
|
||||||
|
|
||||||
[Check console output](${{steps.get-job-link.outputs.result}})
|
[Check console output](${{steps.get-job-link.outputs.result}})
|
||||||
|
|
||||||
- name: Remove comment on PR
|
- name: Remove comment on PR
|
||||||
if: ${{ env.BREAKING_CHANGES_IS_BREAKING == '0' || env.BREAKING_CHANGES_IS_BREAKING == 0 }}
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 0 }}
|
||||||
uses: marocchino/sticky-pull-request-comment@v2
|
uses: marocchino/sticky-pull-request-comment@v2
|
||||||
with:
|
with:
|
||||||
|
number: ${{ steps.finder.outputs.pr }}
|
||||||
delete: true
|
delete: true
|
||||||
|
|
||||||
- name: Add label (if there are breaking changes)
|
- name: Check if "breaking change" label exists
|
||||||
if: ${{ env.BREAKING_CHANGES_IS_BREAKING == '1' || env.BREAKING_CHANGES_IS_BREAKING == 1 }}
|
id: does-label-exist
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
env:
|
||||||
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { data } = await github.rest.issues.listLabelsOnIssue({
|
||||||
|
issue_number: process.env.PR_NUMBER,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
});
|
||||||
|
const labels = data.map(({ name }) => name);
|
||||||
|
const doesExist = labels.includes('breaking change');
|
||||||
|
|
||||||
|
return doesExist;
|
||||||
|
|
||||||
|
- name: Add "breaking change" label
|
||||||
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 1 && steps.does-label-exist.outputs.result == false }}
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v5
|
||||||
env:
|
env:
|
||||||
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
||||||
@ -82,25 +101,49 @@ jobs:
|
|||||||
labels: ['breaking change']
|
labels: ['breaking change']
|
||||||
})
|
})
|
||||||
|
|
||||||
- name: Remove label (if there are breaking changes)
|
- name: Remove "breaking change" label
|
||||||
if: ${{ env.BREAKING_CHANGES_IS_BREAKING == '0' || env.BREAKING_CHANGES_IS_BREAKING == 0 }}
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 0 && steps.does-label-exist.outputs.result == true }}
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v5
|
||||||
env:
|
env:
|
||||||
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
try {
|
github.rest.issues.removeLabel({
|
||||||
github.rest.issues.removeLabel({
|
issue_number: process.env.PR_NUMBER,
|
||||||
issue_number: process.env.PR_NUMBER,
|
owner: context.repo.owner,
|
||||||
owner: context.repo.owner,
|
repo: context.repo.repo,
|
||||||
repo: context.repo.repo,
|
name: 'breaking change'
|
||||||
name: 'breaking change'
|
})
|
||||||
})
|
|
||||||
} catch () {
|
- name: Add "grafana/plugins-platform-frontend" as a reviewer
|
||||||
console.log('"breaking change" label does not exist on the PR.')
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 1 }}
|
||||||
}
|
uses: actions/github-script@v5
|
||||||
|
env:
|
||||||
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.pulls.requestReviewers({
|
||||||
|
pull_number: process.env.PR_NUMBER,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
reviewers: ['grafana/plugins-platform-frontend']
|
||||||
|
})
|
||||||
|
|
||||||
|
- name: Remove "grafana/plugins-platform-frontend" from the list of reviewers
|
||||||
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 0 }}
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
env:
|
||||||
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.pulls.removeRequestedReviewers({
|
||||||
|
pull_number: process.env.PR_NUMBER,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
reviewers: ['grafana/plugins-platform-frontend']
|
||||||
|
})
|
||||||
|
|
||||||
- name: Exit
|
- name: Exit
|
||||||
run: exit ${{ env.BREAKING_CHANGES_IS_BREAKING }}
|
run: exit ${{ steps.breaking-changes.outputs.is_breaking }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ while IFS= read -r line; do
|
|||||||
IFS=':' read -ra ADDR <<< "$line"
|
IFS=':' read -ra ADDR <<< "$line"
|
||||||
PACKAGE_PATH="${ADDR[0]}"
|
PACKAGE_PATH="${ADDR[0]}"
|
||||||
PACKAGE_NAME="${ADDR[1]}"
|
PACKAGE_NAME="${ADDR[1]}"
|
||||||
PACKAGE_VERSION="${ADDR[2]}"
|
|
||||||
|
|
||||||
# Calculate current and previous package paths / names
|
# Calculate current and previous package paths / names
|
||||||
PREV="$PACKAGE_NAME@canary"
|
PREV="$PACKAGE_NAME@canary"
|
||||||
@ -46,8 +45,8 @@ while IFS= read -r line; do
|
|||||||
done <<< "$PACKAGES"
|
done <<< "$PACKAGES"
|
||||||
|
|
||||||
# "Export" the message to an environment variable that can be used across Github Actions steps
|
# "Export" the message to an environment variable that can be used across Github Actions steps
|
||||||
echo "BREAKING_CHANGES_IS_BREAKING=$EXIT_CODE" >> $GITHUB_ENV
|
echo "::set-output name=is_breaking::$EXIT_CODE"
|
||||||
echo "BREAKING_CHANGES_MESSAGE=$GITHUB_MESSAGE" >> $GITHUB_ENV
|
echo "::set-output name=message::$GITHUB_MESSAGE"
|
||||||
|
|
||||||
# We will exit the workflow accordingly at another step
|
# We will exit the workflow accordingly at another step
|
||||||
exit 0
|
exit 0
|
Loading…
Reference in New Issue
Block a user