diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 671e28a..8655843 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -69,3 +69,32 @@ jobs: run: | docker run ${{ matrix.cfg.id }} ctest --test-dir build -C Release docker run ${{ matrix.cfg.id }} ctest --test-dir build -C Debug + + create-issue-when-fault: + runs-on: ubuntu-latest + needs: [test] + if: failure() && github.event_name == 'schedule' + steps: + - uses: actions/checkout@v4 + # See https://github.com/cli/cli/issues/5075 + - name: Create issue + run: | + issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] Build & Test failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end') + + body="**Build-and-Test Failure Report** + - **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z') + - **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) + - **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) + + The scheduled build-and-test triggered by cron has failed. + Please investigate the logs and recent changes associated with this commit." + + echo $body + + if [[ $issue_num -eq -1 ]]; then + gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] Build & Test failure" --body "$body" + else + gh issue comment --repo ${{ github.repository }} $issue_num --body "$body" + fi + env: + GH_TOKEN: ${{ github.token }}