constellation/.github/actions/notify_e2e_failure/action.yml
Markus Rudy b267457541
ci: fix OpenSearch link for e2e notifications (#2813)
* ci: fix OpenSearch link for e2e notifications
2024-01-10 09:49:47 +01:00

98 lines
3.3 KiB
YAML

name: notify e2e failure
description: "Post a failure message to project board and teams"
inputs:
projectWriteToken:
description: "Token to write to the project board"
required: true
test:
description: "Test name"
required: true
provider:
description: "CSP"
required: true
refStream:
description: "RefStream of the run"
required: false
kubernetesVersion:
description: "Kubernetes version"
required: false
clusterCreation:
description: "How the infrastructure for the e2e test was created. One of [cli, self-managed, terraform]."
default: "false"
runs:
using: "composite"
steps:
- name: Pick assignee
id: pick-assignee
uses: ./.github/actions/pick_assignee
- name: Get the current date
id: date
shell: bash
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Create body template
id: body-template
shell: bash
run: |
# TODO(katexochen): add job number when possible
jobURL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# OpenSearch instance details
instance=search-e2e-logs-y46renozy42lcojbvrt3qq7csm
region=eu-central-1
# UUID of index "logs-*"
a="(metadata:(indexPattern:'9004ee20-77cc-11ee-b137-27c60b9ad4a4',view:discover))"
# Default window: last 7 days
g='(time:(from:now-7d,to:now))'
# Query with filters for this workflow run
# TODO(msanft): Add Self-managed param once logcollection is fixed.
q=$(echo "(filters:!(
(query:(match_phrase:(cloud.provider:${{ inputs.provider }}))),
(query:(match_phrase:(metadata.github.run-id:${{ github.run_id }}))),
(query:(match_phrase:(metadata.github.ref-stream:${{ inputs.refStream }}))),
(query:(match_phrase:(metadata.github.kubernetes-version:${{ inputs.kubernetesVersion }}))),
(query:(match_phrase:(metadata.github.e2e-test-payload:${{ inputs.test }})))
))" | tr -d "\t\n ")
# URL construction
opensearchURL="https://${instance}.${region}.es.amazonaws.com/_dashboards/app/data-explorer/discover/#?_a=${a}&_q=${q}&_g=${g}"
cat << EOF > header.md
## Metadata
* [Job URL](${jobURL})
* [OpenSearch URL](${opensearchURL})
EOF
cat header.md .github/failure_project_template.md > body.md
echo "BODY_PATH=$(pwd)/body.md" >> $GITHUB_ENV
- uses: ./.github/actions/gh_create_issue
id: gh_create_issue
with:
title: "${{ env.CURRENT_DATE }}"
body-file: ${{ env.BODY_PATH }}
repo: issues
label: "e2e failure"
assignee: ${{ steps.pick-assignee.outputs.assignee }}
project: Constellation bugs
fields: |
workflow: ${{ github.workflow }}
kubernetesVersion: ${{ inputs.kubernetesVersion }}
cloudProvider: ${{ inputs.provider }}
clusterCreation: ${{ inputs.clusterCreation }}
test: ${{ inputs.test }}
refStream: ${{ inputs.refStream }}
token: ${{ inputs.projectWriteToken }}
- name: Issue URL ${{ steps.gh_create_issue.outputs.issue-url }}
shell: bash
run: echo ${{ steps.gh_create_issue.outputs.issue-url }}