From 1b773dd37e81da321f260e9d1bba8e7ec0adb131 Mon Sep 17 00:00:00 2001 From: Plamen Valentinov Kolev Date: Thu, 13 Mar 2025 17:29:02 +0100 Subject: [PATCH] Add slack messaging to daily and weekly workflows --- .github/workflows/daily.yaml | 26 +++++++++++++++++++++++++- .github/workflows/weekly.yaml | 27 ++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/.github/workflows/daily.yaml b/.github/workflows/daily.yaml index 55dd278..6988ecb 100644 --- a/.github/workflows/daily.yaml +++ b/.github/workflows/daily.yaml @@ -2,11 +2,17 @@ name: Daily collection on: workflow_dispatch: + inputs: + slack_channel: + description: Slack channel to post the error message to if the builds fail. + required: false + default: "sdv-alerts-debug" + schedule: - cron: '0 0 * * *' jobs: - collect: + daily_github_collection: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -24,3 +30,21 @@ jobs: env: PYDRIVE_CREDENTIALS: ${{ secrets.PYDRIVE_CREDENTIALS }} + alert: + needs: [daily_github_collection] + runs-on: ubuntu-latest + if: failure() + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Install slack dependencies + run: | + python -m pip install --upgrade pip + python -m pip install invoke + python -m pip install .[dev] + - name: Slack alert if failure + run: python -m github_analytics.slack_utils -r ${{ github.run_id }} -c ${{ github.event.inputs.slack_channel || 'sdv-alerts' }} + env: + SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} diff --git a/.github/workflows/weekly.yaml b/.github/workflows/weekly.yaml index 3c07842..59ef0c1 100644 --- a/.github/workflows/weekly.yaml +++ b/.github/workflows/weekly.yaml @@ -2,11 +2,17 @@ name: Weekly collection on: workflow_dispatch: + inputs: + slack_channel: + description: Slack channel to post the error message to if the builds fail. + required: false + default: "sdv-alerts-debug" + schedule: - cron: '1 0 * * 0' jobs: - collect: + weekly_github_collection: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -23,3 +29,22 @@ jobs: github-analytics collect -v -q -t ${{ secrets.PERSONAL_ACCESS_TOKEN }} -m -c weekly.yaml env: PYDRIVE_CREDENTIALS: ${{ secrets.PYDRIVE_CREDENTIALS }} + + alert: + needs: [weekly_github_collection] + runs-on: ubuntu-latest + if: failure() + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + - name: Install slack dependencies + run: | + python -m pip install --upgrade pip + python -m pip install invoke + python -m pip install .[dev] + - name: Slack alert if failure + run: python -m github_analytics.slack_utils -r ${{ github.run_id }} -c ${{ github.event.inputs.slack_channel || 'sdv-alerts' }} + env: + SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}