mirror of
https://github.com/grafana/grafana.git
synced 2024-11-21 16:38:03 -06:00
Fix levitate detect breaking changes pipeline not sending slack messages (#94482)
* Fix levitate detect breaking changes pipeline not sending slack messages * Use ref
This commit is contained in:
parent
748bfff601
commit
2a7319809a
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -731,7 +731,6 @@ embed.go @grafana/grafana-as-code
|
||||
/.github/workflows/remove-milestone.yml @grafana/grafana-release-guild
|
||||
/.github/workflows/sbom-report.yml @grafana/security-team
|
||||
/.github/workflows/scripts/json-file-to-job-output.js @grafana/plugins-platform-frontend
|
||||
/.github/workflows/scripts/pr-get-job-link.js @grafana/plugins-platform-frontend
|
||||
/.github/workflows/stale.yml @grafana/grafana-release-guild
|
||||
/.github/workflows/update-changelog.yml @grafana/grafana-release-guild
|
||||
/.github/workflows/update-make-docs.yml @grafana/docs-tooling
|
||||
|
@ -6,6 +6,10 @@ concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
@ -154,26 +158,16 @@ jobs:
|
||||
project_id: 'grafanalabs-global'
|
||||
install_components: 'bq'
|
||||
|
||||
- name: Get link for the Github Action job
|
||||
id: job
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const name = 'Detect breaking changes';
|
||||
const script = require('./.github/workflows/scripts/pr-get-job-link.js')
|
||||
await script({name, github, context, core})
|
||||
|
||||
- name: Detect breaking changes
|
||||
id: breaking-changes
|
||||
run: ./scripts/check-breaking-changes.sh
|
||||
env:
|
||||
FORCE_COLOR: 3
|
||||
GITHUB_JOB_LINK: ${{ steps.job.outputs.link }}
|
||||
|
||||
- name: Persisting the check output
|
||||
run: |
|
||||
mkdir -p ./levitate
|
||||
echo "{ \"exit_code\": ${{ steps.breaking-changes.outputs.is_breaking }}, \"message\": \"${{ steps.breaking-changes.outputs.message }}\", \"job_link\": \"${{ steps.job.outputs.link }}#step:${GITHUB_STEP_NUMBER}:1\", \"pr_number\": \"${{ github.event.pull_request.number }}\" }" > ./levitate/result.json
|
||||
echo "{ \"exit_code\": ${{ steps.breaking-changes.outputs.is_breaking }}, \"message\": \"${{ steps.breaking-changes.outputs.message }}\", \"pr_number\": \"${{ github.event.pull_request.number }}\" }" > ./levitate/result.json
|
||||
|
||||
- name: Upload check output as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
@ -219,15 +213,12 @@ jobs:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
with:
|
||||
script: |
|
||||
const { data } = await github.rest.issues.listLabelsOnIssue({
|
||||
issue_number: process.env.PR_NUMBER,
|
||||
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
});
|
||||
const labels = data.map(({ name }) => name);
|
||||
const doesExist = labels.includes('levitate breaking change');
|
||||
|
||||
return doesExist ? 1 : 0;
|
||||
return labels.some(label => label.name === 'levitate breaking change') ? 1 : 0
|
||||
|
||||
# put the markdown into a variable
|
||||
- name: Levitate Markdown
|
||||
@ -271,22 +262,41 @@ jobs:
|
||||
delete: true
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
|
||||
# Posts a notification to Slack if a PR has a breaking change and it did not have a breaking change before
|
||||
- name: Post to Slack
|
||||
- name: Send Slack Message via Payload
|
||||
id: slack
|
||||
if: steps.levitate-run.outputs.exit_code == 1 && steps.does-label-exist.outputs.result == 0 && env.HAS_SECRETS
|
||||
uses: slackapi/slack-github-action@v1.26.0
|
||||
if: steps.levitate-run.outputs.exit_code == 1 && steps.does-label-exist.outputs.result == 0 && github.repository == 'grafana/grafana'
|
||||
uses: grafana/shared-workflows/actions/send-slack-message@main
|
||||
with:
|
||||
payload: |
|
||||
channel-id: "C031SLFH6G0"
|
||||
payload: |
|
||||
{
|
||||
"pr_link": "https://github.com/grafana/grafana/pull/${{ steps.levitate-run.outputs.pr_number }}",
|
||||
"pr_number": "${{ steps.levitate-run.outputs.pr_number }}",
|
||||
"job_link": "${{ steps.levitate-run.outputs.job_link }}",
|
||||
"message": "${{ steps.levitate-run.outputs.message }}"
|
||||
"channel": "C031SLFH6G0",
|
||||
"text": ":warning: Possible breaking changes detected in *PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }} :warning:",
|
||||
"icon_emoji": ":grot:",
|
||||
"username": "Levitate Bot",
|
||||
"blocks": [
|
||||
{
|
||||
"type": "section",
|
||||
"text": {
|
||||
"type": "mrkdwn",
|
||||
"text": "*grafana/grafana* repository has possible breaking changes"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"fields": [
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": "*PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }}>"
|
||||
},
|
||||
{
|
||||
"type": "mrkdwn",
|
||||
"text": "*Job:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Job>"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
env:
|
||||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_LEVITATE_WEBHOOK_URL }}
|
||||
HAS_SECRETS: ${{ (github.repository == 'grafana/grafana' || secrets.SLACK_LEVITATE_WEBHOOK_URL != '') || '' }}
|
||||
|
||||
# Add the label
|
||||
- name: Add "levitate breaking change" label
|
||||
|
9
.github/workflows/scripts/pr-get-job-link.js
vendored
9
.github/workflows/scripts/pr-get-job-link.js
vendored
@ -1,9 +0,0 @@
|
||||
|
||||
module.exports = async ({ name, github, context, core }) => {
|
||||
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);
|
||||
const job = result.data.jobs.find(j => j.name === name);
|
||||
|
||||
core.setOutput('link', `${job.html_url}?check_suite_focus=true`);
|
||||
}
|
@ -55,7 +55,7 @@ while IFS=" " read -r -a package; do
|
||||
# (non-zero if any of the packages failed the checks)
|
||||
if [ "$STATUS" -gt 0 ]; then
|
||||
EXIT_CODE=1
|
||||
GITHUB_MESSAGE="${GITHUB_MESSAGE}**\\\`${PACKAGE_PATH}\\\`** has possible breaking changes ([more info](${GITHUB_JOB_LINK}#step:${GITHUB_STEP_NUMBER}:1))<br />"
|
||||
GITHUB_MESSAGE="${GITHUB_MESSAGE}**\\\`${PACKAGE_PATH}\\\`** has possible breaking changes<br />"
|
||||
GITHUB_LEVITATE_MARKDOWN+="<h3>${PACKAGE_PATH}</h3>${CURRENT_REPORT}<br>"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user