mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
162 lines
5.2 KiB
YAML
162 lines
5.2 KiB
YAML
name: Levitate
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
build:
|
|
name: Detecting breaking changes
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Install Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '16'
|
|
|
|
- name: Install Yarn
|
|
run: npm install --global yarn
|
|
|
|
# We need this as we can only access the "Run ID" through the context and we need the "Job ID".
|
|
- name: Get link for the Github Action job
|
|
id: get-job-link
|
|
uses: actions/github-script@v5
|
|
with:
|
|
result-encoding: string
|
|
script: |
|
|
const { owner, repo } = context.repo;
|
|
const url = `https://api.github.com/repos/${owner}/${repo}/actions/runs/${context.runId}/jobs`
|
|
const result = await github.request(url)
|
|
console.log(result.data)
|
|
|
|
return `https://github.com/grafana/grafana/runs/${result.data.jobs[0].id}?check_suite_focus=true`;
|
|
|
|
- name: Find current pull request ID
|
|
uses: jwalton/gh-find-current-pr@v1
|
|
id: finder
|
|
|
|
- name: Check if "breaking change" label exists
|
|
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 ? 1 : 0;
|
|
|
|
- name: Debug
|
|
run: echo -e "Job link - ${{steps.get-job-link.outputs.result}} \nPull request - ${{steps.finder.outputs.pr}} \nLabel exists - ${{steps.does-label-exist.outputs.result}}"
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Build packages
|
|
run: yarn packages:build
|
|
|
|
- name: Detect breaking changes
|
|
id: breaking-changes
|
|
run: ./scripts/check-breaking-changes.sh
|
|
env:
|
|
FORCE_COLOR: 3
|
|
GITHUB_JOB_LINK: ${{steps.get-job-link.outputs.result}}
|
|
|
|
- name: Comment on PR
|
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 1 }}
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
|
with:
|
|
number: ${{ steps.finder.outputs.pr }}
|
|
message: |
|
|
⚠️ **Possible breaking changes**
|
|
|
|
_(Open the links below in a new tab to go to the correct steps)_
|
|
|
|
${{ steps.breaking-changes.outputs.message }}
|
|
|
|
[Check console output](${{steps.get-job-link.outputs.result}})
|
|
|
|
- name: Remove comment on PR
|
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 0 }}
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
|
with:
|
|
number: ${{ steps.finder.outputs.pr }}
|
|
delete: true
|
|
|
|
|
|
- name: Add "breaking change" label
|
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 1 && steps.does-label-exist.outputs.result == 0 }}
|
|
uses: actions/github-script@v5
|
|
env:
|
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
|
with:
|
|
script: |
|
|
github.rest.issues.addLabels({
|
|
issue_number: process.env.PR_NUMBER,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: ['breaking change']
|
|
})
|
|
|
|
- name: Remove "breaking change" label
|
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 0 && steps.does-label-exist.outputs.result == 1 }}
|
|
uses: actions/github-script@v5
|
|
env:
|
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
|
with:
|
|
script: |
|
|
github.rest.issues.removeLabel({
|
|
issue_number: process.env.PR_NUMBER,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
name: 'breaking change'
|
|
})
|
|
|
|
# This is very weird, the actual request goes through (comes back with a 201), but does not assign the team.
|
|
# Related issue: https://github.com/renovatebot/renovate/issues/1908
|
|
- name: Add "grafana/plugins-platform-frontend" as a reviewer
|
|
if: ${{ steps.breaking-changes.outputs.is_breaking == 1 }}
|
|
uses: actions/github-script@v5
|
|
env:
|
|
PR_NUMBER: ${{ steps.finder.outputs.pr }}
|
|
with:
|
|
script: |
|
|
const response = await github.rest.pulls.requestReviewers({
|
|
pull_number: process.env.PR_NUMBER,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
reviewers: [],
|
|
team_reviewers: ['grafana/plugins-platform-frontend']
|
|
})
|
|
|
|
console.log(response)
|
|
|
|
- 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: |
|
|
const response = await github.rest.pulls.removeRequestedReviewers({
|
|
pull_number: process.env.PR_NUMBER,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
reviewers: [],
|
|
team_reviewers: ['grafana/plugins-platform-frontend']
|
|
})
|
|
|
|
console.log(response)
|
|
|
|
- name: Exit
|
|
run: exit ${{ steps.breaking-changes.outputs.is_breaking }}
|
|
shell: bash
|
|
|