This commit is contained in:
Trask Stalnaker 2023-05-04 07:15:30 -07:00 коммит произвёл GitHub
Родитель 6b83440ad6
Коммит 9442a58882
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 44 добавлений и 0 удалений

Просмотреть файл

@ -29,3 +29,11 @@ jobs:
uses: actions/upload-artifact@v3
with:
path: agent/agent/build/reports
scheduled-job-notification:
needs:
- analyze
if: always()
uses: ./.github/workflows/reusable-scheduled-job-notification.yml
with:
success: ${{ needs.analyze.result == 'success' }}

36
.github/workflows/reusable-scheduled-job-notification.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,36 @@
name: Reusable - Scheduled job notification
on:
workflow_call:
inputs:
success:
type: boolean
required: true
jobs:
notify-if-needed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Open issue or add comment if issue already open
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
number=$(gh issue list --search "Workflow failed: $GITHUB_WORKFLOW" --limit 1 --json number -q .[].number)
echo $number
echo ${{ inputs.success }}
if [[ $number ]]; then
if [[ ${{ inputs.success }} == "true" ]]; then
gh issue close $number
else
gh issue comment $number \
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
fi
elif [[ !${{ inputs.success }} ]]; then
gh issue create --title "Workflow failed: $GITHUB_WORKFLOW (#$GITHUB_RUN_NUMBER)" \
--label bug \
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
fi