]> gitweb.fluxo.info Git - puppet-mailalias_core.git/commitdiff
(MODULES-10815) Add Slack notification for daily test run
authorLuchian Nemes <luchian.nemes@puppet.com>
Thu, 24 Sep 2020 07:12:11 +0000 (10:12 +0300)
committerLuchian Nemes <luchian.nemes@puppet.com>
Wed, 30 Sep 2020 07:02:32 +0000 (10:02 +0300)
Starting with this commit, the daily `Unit Tests with nightly Puppet
gem` run will now send the job result via a Slack notification. The
Slack channel can be changed through the `SLACK_CHANNEL` from the GitHub
Secrets of the repository.

.github/workflows/daily_unit_tests_with_nightly_puppet_gem.yaml

index b31bf181140169f3784b1b745f8ac36b084fc4e6..303be8c7191eb10ba713dfe55d5802731bb06697 100644 (file)
@@ -56,3 +56,51 @@ jobs:
 
       - name: Run unit tests
         run: bundle exec rake parallel_spec
+
+      - name: Send Slack notification
+        if: always()
+        shell: bash
+        env:
+          success: '#43c78a'
+          failure: '#ed5c5c'
+          cancelled: '#343434'
+        run: |
+          curl -X POST --data-urlencode \
+            "payload=\
+            {\
+              'channel': '#${{ secrets.SLACK_CHANNEL }}', \
+              'attachments': \
+              [\
+                {\
+                  'author_name': '${{ github.actor }}', \
+                  'author_link': 'http://github.com/${{ github.actor }}', \
+                  'author_icon': 'http://github.com/${{ github.actor }}.png?size=32', \
+                  'color': '${{ env[job.status] }}', \
+                  'fields': \
+                  [\
+                    {\
+                      'title': 'Git reference', \
+                      'value': '${{ github.ref }}', \
+                      'short': true, \
+                    },\
+                    {\
+                      'title': 'Event', \
+                      'value': '${{ github.event_name }}', \
+                      'short': true, \
+                    },\
+                    {\
+                      'title': 'Workflow', \
+                      'value': '<http://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>', \
+                    },\
+                    {\
+                      'title': ':ci_${{ job.status}}: *${{ github.repository }}*', \
+                      'value': 'The *${{ matrix.os_type }} / Puppet${{ matrix.puppet_version }} gem / Ruby ${{ matrix.ruby }}* run finished with status *${{ job.status }}*.', \
+                      'short': false, \
+                    },\
+                  ],\
+                  'footer': ':githublogo: Commit SHA: <http://github.com/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>', \
+                },\
+              ],\
+            }\
+            " \
+            ${{ secrets.SLACK_WEBHOOK_URL }}