From 3236fd856f9232ec718c4a98180d39d6d7a706c4 Mon Sep 17 00:00:00 2001 From: Moritz Wiesinger Date: Mon, 16 Dec 2024 15:59:10 +0100 Subject: [PATCH] create issue when nightly tests fail Signed-off-by: Moritz Wiesinger --- .github/workflows/base-package-tests.yaml | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/base-package-tests.yaml b/.github/workflows/base-package-tests.yaml index a58179e8..0c1db3f3 100644 --- a/.github/workflows/base-package-tests.yaml +++ b/.github/workflows/base-package-tests.yaml @@ -9,6 +9,11 @@ on: distribution: required: true type: string + issue-on-failure: + required: false + type: boolean + default: false + description: "Set to true if a GH issue should be generated upon failure" jobs: package-tests: @@ -28,3 +33,29 @@ jobs: - name: Test ${{ matrix.type }} package run: ./scripts/package-tests/package-tests.sh ./otelcol*-SNAPSHOT-*_linux_amd64.${{ matrix.type }} ${{ inputs.distribution }} + + create-issue: + name: Create GitHub Issue + runs-on: ubuntu-24.04 + needs: [package-tests] + if: failure() && inputs.issue-on-failure == 'true' + steps: + - name: Formulate issue + id: formulate_issue + run: | + # create a markdown file that contains details about the failure + echo "The nightly linux package tests failed in the following GitHub actions run." > nightly-test-failure.md + echo "* Link to run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> nightly-test-failure.md + echo "* Triggered by: Nightly scheduled build" >> nightly-test-failure.md + echo "" >> nightly-test-failure.md + echo "Note: This issue was auto-generated from [base-package-tests.yaml](https://github.com/open-telemetry/opentelemetry-collector-releases/blob/main/.github/workflows/base-package-tests.yaml)" >> nightly-test-failure.md + + - name: Create issue on failure + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + run: | + gh issue create \ + --repo open-telemetry/opentelemetry-collector-contrib \ + --title "Nightly Linux Package Tests Failed" \ + --body-file nightly-test-failure.md \ + --label "release:blocker"