mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
105 lines
3.7 KiB
YAML
105 lines
3.7 KiB
YAML
name: Run commands when issues are opened
|
|
on:
|
|
issues:
|
|
types: [opened]
|
|
concurrency:
|
|
group: issue-opened-${{ github.event.issue.number }}
|
|
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
jobs:
|
|
main:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Actions
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: "grafana/grafana-github-actions"
|
|
path: ./actions
|
|
ref: main
|
|
- name: Install Actions
|
|
run: npm install --production --prefix ./actions
|
|
# give issue-openers a chance to add labels after submit
|
|
- name: Sleep for 2 minutes
|
|
run: sleep 2m
|
|
shell: bash
|
|
- name: Run Commands
|
|
uses: ./actions/commands
|
|
with:
|
|
metricsWriteAPIKey: ${{secrets.GRAFANA_MISC_STATS_API_KEY}}
|
|
token: ${{secrets.ISSUE_COMMANDS_TOKEN}}
|
|
configPath: "issue-opened"
|
|
config:
|
|
runs-on: "ubuntu-latest"
|
|
outputs:
|
|
has-secrets: ${{ steps.check.outputs.has-secrets }}
|
|
steps:
|
|
- name: "Check for secrets"
|
|
id: check
|
|
shell: bash
|
|
run: |
|
|
if [ -n "${{ (secrets.GRAFANA_DELIVERY_BOT_APP_ID != '' &&
|
|
secrets.GRAFANA_DELIVERY_BOT_APP_PEM != ''
|
|
) || '' }}" ]; then
|
|
echo "has-secrets=1" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
auto-triage:
|
|
needs: [main, config]
|
|
if: needs.config.outputs.has-secrets && (github.event.issue.author_association == 'NONE' || github.event.issue.author_association == 'FIRST_TIMER' || github.event.issue.author_association == 'FIRST_TIME_CONTRIBUTOR')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: "Generate token"
|
|
id: generate_token
|
|
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
|
|
with:
|
|
app_id: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_ID }}
|
|
private_key: ${{ secrets.GRAFANA_DELIVERY_BOT_APP_PEM }}
|
|
|
|
- name: "Get vault secrets"
|
|
id: vault-secrets
|
|
uses: grafana/shared-workflows/actions/get-vault-secrets@main
|
|
with:
|
|
# Secrets placed in the ci/repo/grafana/<repo>/<path> path in Vault
|
|
repo_secrets: |
|
|
AUTOTRIAGER_OPENAI_API_KEY=plugins_platform_issue_triager:AUTOTRIAGER_OPENAI_API_KEY
|
|
AUTOTRIAGER_SLACK_WEBHOOK_URL=plugins_platform_issue_triager:AUTOTRIAGER_SLACK_WEBHOOK_URL
|
|
|
|
- name: Checkout auto-triager repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: grafana/auto-triager
|
|
path: auto-triager
|
|
token: ${{ steps.generate_token.outputs.token }}
|
|
|
|
- name: Send issue to the auto triager action
|
|
id: auto_triage
|
|
# https://github.com/grafana/auto-triager/blob/main/action.yml
|
|
#uses: grafana/auto-triager@main
|
|
uses: ./auto-triager
|
|
with:
|
|
token: ${{ steps.generate_token.outputs.token }}
|
|
issue_number: ${{ github.event.issue.number }}
|
|
openai_api_key: ${{ env.AUTOTRIAGER_OPENAI_API_KEY }}
|
|
add_labels: true
|
|
|
|
- name: Labels from auto triage
|
|
run: |
|
|
echo ${{ steps.auto_triage.outputs.triage_labels }}
|
|
|
|
- name: "Send Slack notification"
|
|
if : ${{ steps.auto_triage.outputs.triage_labels != '' }}
|
|
uses: slackapi/slack-github-action@v1.27.0
|
|
with:
|
|
payload: >
|
|
{
|
|
"icon_emoji": ":robocto:",
|
|
"username": "Auto Triager",
|
|
"type": "mrkdwn",
|
|
"text": "Auto triager found the following labels: ${{ steps.auto_triage.outputs.triage_labels }} for issue ${{ github.event.issue.html_url }}",
|
|
"channel": "#triage-automation-ci"
|
|
}
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ env.AUTOTRIAGER_SLACK_WEBHOOK_URL }}
|