2022-01-03 05:48:12 -06:00
|
|
|
name: Levitate / Report breaking changes
|
2021-12-15 10:07:11 -06:00
|
|
|
|
2022-01-03 05:48:12 -06:00
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows: ["Levitate / Detect breaking changes"]
|
|
|
|
types: [completed]
|
2021-12-15 10:07:11 -06:00
|
|
|
|
|
|
|
jobs:
|
2022-01-03 05:48:12 -06:00
|
|
|
notify:
|
|
|
|
name: Report
|
2021-12-15 10:07:11 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2022-01-03 05:48:12 -06:00
|
|
|
- name: Setup environment
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
2022-01-03 05:48:12 -06:00
|
|
|
node-version: 16
|
|
|
|
- run: npm install adm-zip
|
2021-12-15 10:07:11 -06:00
|
|
|
|
2022-01-03 05:48:12 -06:00
|
|
|
- name: Download artifact
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: actions/github-script@v5
|
2022-01-03 05:48:12 -06:00
|
|
|
id: download-artifact
|
|
|
|
env:
|
|
|
|
RUN_ID: ${{github.event.workflow_run.id }}
|
2021-12-15 10:07:11 -06:00
|
|
|
with:
|
|
|
|
result-encoding: string
|
|
|
|
script: |
|
2022-01-03 05:48:12 -06:00
|
|
|
const runId = process.env.RUN_ID;
|
|
|
|
const artifactName = 'levitate';
|
|
|
|
const script = require('./.github/workflows/scripts/get-workflow-run-artifact.js');
|
|
|
|
return await script({ github, context, core, runId, artifactName });
|
|
|
|
|
|
|
|
- name: Parsing levitate result
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
id: levitate-run
|
|
|
|
env:
|
|
|
|
ARTIFACT_FOLDER: ${{ steps.download-artifact.outputs.result }}
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const filePath = `${process.env.ARTIFACT_FOLDER}/result.json`;
|
|
|
|
const script = require('./.github/workflows/scripts/json-file-to-job-output.js');
|
|
|
|
await script({ core, filePath });
|
2021-12-15 10:07:11 -06:00
|
|
|
|
|
|
|
- name: Check if "breaking change" label exists
|
|
|
|
id: does-label-exist
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
env:
|
2022-01-03 05:48:12 -06:00
|
|
|
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
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: Comment on PR
|
2022-01-03 05:48:12 -06:00
|
|
|
if: ${{ steps.levitate-run.outputs.exit_code == 1 }}
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
|
|
|
with:
|
2022-01-03 05:48:12 -06:00
|
|
|
number: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
message: |
|
|
|
|
⚠️ **Possible breaking changes**
|
|
|
|
|
|
|
|
_(Open the links below in a new tab to go to the correct steps)_
|
|
|
|
|
2022-01-03 05:48:12 -06:00
|
|
|
${{ steps.levitate-run.outputs.message }}
|
2021-12-15 10:07:11 -06:00
|
|
|
|
2022-01-03 05:48:12 -06:00
|
|
|
[Check console output](${{ steps.levitate-run.outputs.job_link }})
|
2021-12-15 10:07:11 -06:00
|
|
|
|
|
|
|
- name: Remove comment on PR
|
2022-01-03 05:48:12 -06:00
|
|
|
if: ${{ steps.levitate-run.outputs.exit_code == 0 }}
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
|
|
|
with:
|
2022-01-03 05:48:12 -06:00
|
|
|
number: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
delete: true
|
|
|
|
|
|
|
|
|
|
|
|
- name: Add "breaking change" label
|
2022-01-03 05:48:12 -06:00
|
|
|
if: ${{ steps.levitate-run.outputs.exit_code == 1 && steps.does-label-exist.outputs.result == 0 }}
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: actions/github-script@v5
|
|
|
|
env:
|
2022-01-03 05:48:12 -06:00
|
|
|
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
with:
|
|
|
|
script: |
|
2022-01-03 05:48:12 -06:00
|
|
|
await github.rest.issues.addLabels({
|
2021-12-15 10:07:11 -06:00
|
|
|
issue_number: process.env.PR_NUMBER,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
labels: ['breaking change']
|
|
|
|
})
|
|
|
|
|
|
|
|
- name: Remove "breaking change" label
|
2022-01-03 05:48:12 -06:00
|
|
|
if: ${{ steps.levitate-run.outputs.exit_code == 0 && steps.does-label-exist.outputs.result == 1 }}
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: actions/github-script@v5
|
|
|
|
env:
|
2022-01-03 05:48:12 -06:00
|
|
|
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
with:
|
|
|
|
script: |
|
2022-01-03 05:48:12 -06:00
|
|
|
await github.rest.issues.removeLabel({
|
2021-12-15 10:07:11 -06:00
|
|
|
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
|
2022-01-03 05:48:12 -06:00
|
|
|
if: ${{ steps.levitate-run.outputs.exit_code == 1 }}
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: actions/github-script@v5
|
|
|
|
env:
|
2022-01-03 05:48:12 -06:00
|
|
|
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
with:
|
|
|
|
script: |
|
2022-01-03 05:48:12 -06:00
|
|
|
await github.rest.pulls.requestReviewers({
|
2021-12-15 10:07:11 -06:00
|
|
|
pull_number: process.env.PR_NUMBER,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
reviewers: [],
|
|
|
|
team_reviewers: ['grafana/plugins-platform-frontend']
|
2022-01-03 05:48:12 -06:00
|
|
|
});
|
2021-12-15 10:07:11 -06:00
|
|
|
|
|
|
|
- name: Remove "grafana/plugins-platform-frontend" from the list of reviewers
|
2022-01-03 05:48:12 -06:00
|
|
|
if: ${{ steps.levitate-run.outputs.exit_code == 0 }}
|
2021-12-15 10:07:11 -06:00
|
|
|
uses: actions/github-script@v5
|
|
|
|
env:
|
2022-01-03 05:48:12 -06:00
|
|
|
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
|
2021-12-15 10:07:11 -06:00
|
|
|
with:
|
|
|
|
script: |
|
2022-01-03 05:48:12 -06:00
|
|
|
await github.rest.pulls.removeRequestedReviewers({
|
2021-12-15 10:07:11 -06:00
|
|
|
pull_number: process.env.PR_NUMBER,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
reviewers: [],
|
|
|
|
team_reviewers: ['grafana/plugins-platform-frontend']
|
2022-01-03 05:48:12 -06:00
|
|
|
});
|
2021-12-15 10:07:11 -06:00
|
|
|
|
|
|
|
- name: Exit
|
2022-01-03 05:48:12 -06:00
|
|
|
run: exit ${{ steps.levitate-run.outputs.exit_code }}
|
2021-12-15 10:07:11 -06:00
|
|
|
shell: bash
|
|
|
|
|