From 8091de841506ff8c7bff6a47df976720d8b84e95 Mon Sep 17 00:00:00 2001 From: Kartikey Mamgain Date: Tue, 8 Aug 2023 12:45:32 +0530 Subject: [PATCH] workflow to send codeql result as slack notification Signed-off-by: Kartikey Mamgain --- .github/workflows/codeql-analysis.yml | 39 ++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 71d5627276a..3ad2310fd1e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,10 +13,10 @@ name: "CodeQL" on: push: - branches: [ main ] + branches: [ release-3.11 ] pull_request: # The branches below must be a subset of the branches above - branches: [ main ] + branches: [ release-3.11 ] schedule: - cron: '29 6 * * 6' @@ -35,11 +35,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # pin@v3.5.3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -50,7 +50,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # ℹī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -64,4 +64,31 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + id: codeql_analysis + uses: github/codeql-action/analyze@v2 # pinv2.21.2 + + - name: Send message to helm_dev slack channel + id: notify_dev + if: ${{ always() && github.event_name == 'schedule' && steps.codeql_analysis.conclusion != 'success' }} + uses: archive/github-actions-slack@v2.7.0 + with: + slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }} + slack-channel: C02979BDUPL + slack-text: Failure! CodeQL analysis for Helm downstream. See '${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}' + + - name: Result from "Send Message to helm_dev slack channel" + if: ${{ always() && github.event_name == 'schedule' && steps.codeql_analysis.conclusion != 'success' }} + run: echo "The result was ${{ steps.notify_dev.outputs.slack-result }}" + + - name: Send message to helm_notify slack channel + id: notify + if: ${{ always() && github.event_name == 'schedule' && steps.codeql_analysis.conclusion == 'success' }} + uses: archive/github-actions-slack@v2.7.0 + with: + slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }} + slack-channel: C04K1ARMH8A + slack-text: Success! CodeQL analysis for Helm downstream. See '${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}' + + - name: Result from "Send Message to helm_notify slack channel" + if: ${{ always() && github.event_name == 'schedule' && steps.codeql_analysis.conclusion == 'success' }} + run: echo "The result was ${{ steps.notify.outputs.slack-result }}" \ No newline at end of file