mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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/remove-milestone.yml @grafana/grafana-release-guild
|
||||||
/.github/workflows/sbom-report.yml @grafana/security-team
|
/.github/workflows/sbom-report.yml @grafana/security-team
|
||||||
/.github/workflows/scripts/json-file-to-job-output.js @grafana/plugins-platform-frontend
|
/.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/stale.yml @grafana/grafana-release-guild
|
||||||
/.github/workflows/update-changelog.yml @grafana/grafana-release-guild
|
/.github/workflows/update-changelog.yml @grafana/grafana-release-guild
|
||||||
/.github/workflows/update-make-docs.yml @grafana/docs-tooling
|
/.github/workflows/update-make-docs.yml @grafana/docs-tooling
|
||||||
|
@ -6,6 +6,10 @@ concurrency:
|
|||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
@ -154,26 +158,16 @@ jobs:
|
|||||||
project_id: 'grafanalabs-global'
|
project_id: 'grafanalabs-global'
|
||||||
install_components: 'bq'
|
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
|
- name: Detect breaking changes
|
||||||
id: 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
|
||||||
GITHUB_JOB_LINK: ${{ steps.job.outputs.link }}
|
|
||||||
|
|
||||||
- name: Persisting the check output
|
- name: Persisting the check output
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./levitate
|
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
|
- name: Upload check output as artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@ -219,15 +213,12 @@ jobs:
|
|||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const { data } = await github.rest.issues.listLabelsOnIssue({
|
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
|
||||||
issue_number: process.env.PR_NUMBER,
|
issue_number: context.issue.number,
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
});
|
});
|
||||||
const labels = data.map(({ name }) => name);
|
return labels.some(label => label.name === 'levitate breaking change') ? 1 : 0
|
||||||
const doesExist = labels.includes('levitate breaking change');
|
|
||||||
|
|
||||||
return doesExist ? 1 : 0;
|
|
||||||
|
|
||||||
# put the markdown into a variable
|
# put the markdown into a variable
|
||||||
- name: Levitate Markdown
|
- name: Levitate Markdown
|
||||||
@ -271,22 +262,41 @@ jobs:
|
|||||||
delete: true
|
delete: true
|
||||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
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: Send Slack Message via Payload
|
||||||
- name: Post to Slack
|
|
||||||
id: slack
|
id: slack
|
||||||
if: steps.levitate-run.outputs.exit_code == 1 && steps.does-label-exist.outputs.result == 0 && env.HAS_SECRETS
|
if: steps.levitate-run.outputs.exit_code == 1 && steps.does-label-exist.outputs.result == 0 && github.repository == 'grafana/grafana'
|
||||||
uses: slackapi/slack-github-action@v1.26.0
|
uses: grafana/shared-workflows/actions/send-slack-message@main
|
||||||
with:
|
with:
|
||||||
payload: |
|
channel-id: "C031SLFH6G0"
|
||||||
|
payload: |
|
||||||
{
|
{
|
||||||
"pr_link": "https://github.com/grafana/grafana/pull/${{ steps.levitate-run.outputs.pr_number }}",
|
"channel": "C031SLFH6G0",
|
||||||
"pr_number": "${{ steps.levitate-run.outputs.pr_number }}",
|
"text": ":warning: Possible breaking changes detected in *PR:* <${{ github.event.pull_request.html_url }}|#${{ github.event.pull_request.number }} :warning:",
|
||||||
"job_link": "${{ steps.levitate-run.outputs.job_link }}",
|
"icon_emoji": ":grot:",
|
||||||
"message": "${{ steps.levitate-run.outputs.message }}"
|
"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
|
# Add the label
|
||||||
- name: Add "levitate breaking change" 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)
|
# (non-zero if any of the packages failed the checks)
|
||||||
if [ "$STATUS" -gt 0 ]; then
|
if [ "$STATUS" -gt 0 ]; then
|
||||||
EXIT_CODE=1
|
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>"
|
GITHUB_LEVITATE_MARKDOWN+="<h3>${PACKAGE_PATH}</h3>${CURRENT_REPORT}<br>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user