From 1b7d35b16c3a0705dfc646caf8d0f253f6b2779b Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Tue, 9 Apr 2024 10:25:14 +0100 Subject: [PATCH] Create issue if nightly fails (#1333) Fixes #1276. --- .github/actions/create_issue/action.yml | 27 +++++++++++++++++++++++++ .github/workflows/clang-tidy.yml | 16 +++++++-------- .github/workflows/nightly.yml | 18 +++++++++++++++++ 3 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 .github/actions/create_issue/action.yml diff --git a/.github/actions/create_issue/action.yml b/.github/actions/create_issue/action.yml new file mode 100644 index 00000000..2e967249 --- /dev/null +++ b/.github/actions/create_issue/action.yml @@ -0,0 +1,27 @@ +name: Create an issue +description: Create an issue +inputs: + title: + description: Issue title + required: true + body: + description: Issue body + required: true +outputs: + created_issue_id: + description: Created issue id + value: ${{ steps.create_issue.outputs.created_issue }} +runs: + using: composite + steps: + - name: Create an issue + id: create_issue + shell: bash + run: | + echo -e '${{ inputs.body }}' > issue.md + gh issue create --assignee 'cindyyan317,godexsoft,kuznetsss' --label bug --title '${{ inputs.title }}' --body-file ./issue.md > create_issue.log + created_issue=$(cat create_issue.log | sed 's|.*/||') + echo "created_issue=$created_issue" >> $GITHUB_OUTPUT + rm create_issue.log issue.md + + diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 24aba0c0..dd21e0ef 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -76,16 +76,14 @@ jobs: - name: Create an issue if: ${{ steps.run_clang_tidy.outcome != 'success' }} id: create_issue - shell: bash + uses: ./.github/actions/create_issue env: GH_TOKEN: ${{ github.token }} - run: | - echo -e 'Clang-tidy found issues in the code:\n' > issue.md - echo -e "List of the issues found: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/" >> issue.md - gh issue create --assignee 'cindyyan317,godexsoft,kuznetsss' --label bug --title 'Clang-tidy found bugs in codeπŸ›' --body-file ./issue.md > create_issue.log - created_issue=$(cat create_issue.log | sed 's|.*/||') - echo "created_issue=$created_issue" >> $GITHUB_OUTPUT - rm create_issue.log issue.md + with: + title: 'Clang-tidy found bugs in code πŸ›' + body: > + Clang-tidy found issues in the code: + List of the issues found: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/ - uses: crazy-max/ghaction-import-gpg@v5 if: ${{ steps.run_clang_tidy.outcome != 'success' }} @@ -108,7 +106,7 @@ jobs: branch-suffix: timestamp delete-branch: true title: "[CI] clang-tidy auto fixes" - body: "Fixes #${{ steps.create_issue.outputs.created_issue }}. Please review and commit clang-tidy fixes." + body: "Fixes #${{ steps.create_issue.outputs.created_issue_id }}. Please review and commit clang-tidy fixes." reviewers: "cindyyan317,godexsoft,kuznetsss" - name: Fail the job diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c3d7175c..360a97c2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -149,3 +149,21 @@ jobs: gh release create nightly --prerelease --title "Clio development (nightly) build" \ --target $GITHUB_SHA --notes-file "${RUNNER_TEMP}/nightly_notes.md" \ ./nightly_release/clio_server* + + create_issue_on_failure: + needs: [build, run_tests, nightly_release] + if: ${{ always() && contains(needs.*.result, 'failure') }} + runs-on: ubuntu-20.04 + permissions: + contents: write + issues: write + steps: + - name: Create an issue + uses: ./.github/actions/create_issue + env: + GH_TOKEN: ${{ github.token }} + with: + title: 'Nightly release failed πŸŒ™' + body: > + Nightly release failed: + Workflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/