diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index 494c90a2..f862c838 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -8,6 +8,11 @@ on: description: 'The reference to checkout before running the acceptance tests. Used to run the tests on a fork.' required: true type: string + notify_slack_on_failure: + description: 'Whether to notify slack or not.' + required: false + default: false + type: boolean secrets: tl_client_id: required: true @@ -17,6 +22,8 @@ on: required: true tl_signing_private_key: required: true + slack_webhook_url: + required: false jobs: acceptance-tests: @@ -39,4 +46,51 @@ jobs: TL_CLIENT_SECRET: ${{ secrets.tl_client_secret }} TL_SIGNING_KEY_ID: ${{ secrets.tl_signing_key_id }} TL_SIGNING_PRIVATE_KEY: ${{ secrets.tl_signing_private_key }} - run: ./gradlew acceptance-tests \ No newline at end of file + run: ./gradlew acceptance-tests + notify-slack: + needs: acceptance-tests + runs-on: ubuntu-latest + if: ${{ always() && contains(needs.*.result, 'failure') && inputs.notify_slack_on_failure == true }} + steps: + - name: Notify slack + uses: slackapi/slack-github-action@v1.24.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.slack_webhook_url }} + # type is required for custom payloads + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + with: + payload: | + { + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":fire: *Acceptance tests* are failing in *Sandbox* on our *Java* backend library! :java:" + } + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": ":eyes: View on Github" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + }, + { + "type": "image", + "title": { + "type": "plain_text", + "text": "I don't like that", + "emoji": true + }, + "image_url": "https://media.giphy.com/media/4cuyucPeVWbNS/giphy.gif", + "alt_text": "marg" + } + ] + } \ No newline at end of file diff --git a/.github/workflows/workflow-scheduled-acceptance-tests.yml b/.github/workflows/workflow-scheduled-acceptance-tests.yml index 89a855ce..15304bfe 100644 --- a/.github/workflows/workflow-scheduled-acceptance-tests.yml +++ b/.github/workflows/workflow-scheduled-acceptance-tests.yml @@ -3,15 +3,18 @@ name: Scheduled acceptance tests in Sandbox environment on: schedule: - - cron: "0 7-19/2 * * *" # every 2 hours between 10 and 20 (UTC) + # every hour between 8 and 19 UTC time + - cron: "0 8-19/1 * * *" jobs: scheduled-acceptance-tests: uses: ./.github/workflows/acceptance-tests.yml with: - checkout_ref: /refs/heads/main + notify_slack_on_failure: true + checkout_ref: main secrets: tl_client_id: ${{ secrets.ACCEPTANCE_TEST_CLIENT_ID }} tl_client_secret: ${{ secrets.ACCEPTANCE_TEST_CLIENT_SECRET }} tl_signing_key_id: ${{ secrets.ACCEPTANCE_TEST_SIGNING_KEY_ID }} - tl_signing_private_key: ${{ secrets.ACCEPTANCE_TEST_SIGNING_PRIVATE_KEY }} \ No newline at end of file + tl_signing_private_key: ${{ secrets.ACCEPTANCE_TEST_SIGNING_PRIVATE_KEY }} + slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL}} \ No newline at end of file diff --git a/README.md b/README.md index a96ac0fa..5c36165f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # TrueLayer Java -[![Release final version](https://github.com/TrueLayer/truelayer-java/actions/workflows/release-final.yml/badge.svg)](https://github.com/TrueLayer/truelayer-java/actions/workflows/release-final.yml) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.truelayer/truelayer-java/badge.svg?style=flat)](https://search.maven.org/artifact/com.truelayer/truelayer-java) [![javadoc](https://javadoc.io/badge2/com.truelayer/truelayer-java/javadoc.svg)](https://javadoc.io/doc/com.truelayer/truelayer-java) [![Coverage Status](https://coveralls.io/repos/github/TrueLayer/truelayer-java/badge.svg?t=gcGKQv)](https://coveralls.io/github/TrueLayer/truelayer-java) +[![Scheduled acceptance tests in Sandbox environment](https://github.com/TrueLayer/truelayer-java/actions/workflows/workflow-scheduled-acceptance-tests.yml/badge.svg)](https://github.com/TrueLayer/truelayer-java/actions/workflows/workflow-scheduled-acceptance-tests.yml) [![License](https://img.shields.io/:license-mit-blue.svg)](https://truelayer.mit-license.org/) The official [TrueLayer](https://truelayer.com) Java client provides convenient access to TrueLayer APIs from applications built with Java.