From 3bc0c4feda0b90c10c28956c0114f8934d8f287c Mon Sep 17 00:00:00 2001 From: liyang Date: Sun, 18 Feb 2024 21:13:04 +0800 Subject: [PATCH] ci: add release result send to slack (#3312) * feat: add notify release result to slack * chore: change build image output result name --------- Co-authored-by: tison --- .github/workflows/dev-build.yml | 4 ++-- .github/workflows/release.yml | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-build.yml b/.github/workflows/dev-build.yml index 3d2bd14a0717..66ccfa6922d0 100644 --- a/.github/workflows/dev-build.yml +++ b/.github/workflows/dev-build.yml @@ -330,14 +330,14 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DEVELOP_CHANNEL }} steps: - - name: Notifiy nightly build successful result + - name: Notifiy dev build successful result uses: slackapi/slack-github-action@v1.23.0 if: ${{ needs.release-images-to-dockerhub.outputs.build-result == 'success' }} with: payload: | {"text": "GreptimeDB's ${{ env.NEXT_RELEASE_VERSION }} build has completed successfully."} - - name: Notifiy nightly build failed result + - name: Notifiy dev build failed result uses: slackapi/slack-github-action@v1.23.0 if: ${{ needs.release-images-to-dockerhub.outputs.build-result != 'success' }} with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d5fc07a98e5..7e48f0a204d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -240,6 +240,11 @@ jobs: disable-run-tests: ${{ env.DISABLE_RUN_TESTS }} artifacts-dir: ${{ matrix.artifacts-dir-prefix }}-${{ needs.allocate-runners.outputs.version }} + - name: Set build macos result + id: set-build-macos-result + run: | + echo "build-macos-result=success" >> $GITHUB_OUTPUT + build-windows-artifacts: name: Build Windows artifacts strategy: @@ -276,6 +281,11 @@ jobs: disable-run-tests: ${{ env.DISABLE_RUN_TESTS }} artifacts-dir: ${{ matrix.artifacts-dir-prefix }}-${{ needs.allocate-runners.outputs.version }} + - name: Set build windows result + id: set-build-windows-result + run: | + echo "build-windows-result=success" >> $GITHUB_OUTPUT + release-images-to-dockerhub: name: Build and push images to DockerHub if: ${{ inputs.release_images || github.event_name == 'push' || github.event_name == 'schedule' }} @@ -299,6 +309,11 @@ jobs: image-registry-password: ${{ secrets.DOCKERHUB_TOKEN }} version: ${{ needs.allocate-runners.outputs.version }} + - name: Set build image result + id: set-image-build-result + run: | + echo "build-image-result=success" >> $GITHUB_OUTPUT + release-cn-artifacts: name: Release artifacts to CN region if: ${{ inputs.release_images || github.event_name == 'push' || github.event_name == 'schedule' }} @@ -413,3 +428,27 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ vars.EC2_RUNNER_REGION }} github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + + notification: + if: ${{ always() }} # Not requiring successful dependent jobs, always run. + name: Send notification to Greptime team + needs: [ + release-images-to-dockerhub + ] + runs-on: ubuntu-20.04 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DEVELOP_CHANNEL }} + steps: + - name: Notifiy release successful result + uses: slackapi/slack-github-action@v1.23.0 + if: ${{ needs.release-images-to-dockerhub.outputs.build-image-result == 'success' && needs.build-windows-artifacts.outputs.build-windows-result == 'success' && needs.build-macos-artifacts.outputs.build-macos-result == 'success' }} + with: + payload: | + {"text": "GreptimeDB's release version ${{ needs.allocate-runners.outputs.version }} has completed successfully."} + + - name: Notifiy release failed result + uses: slackapi/slack-github-action@v1.23.0 + if: ${{ needs.release-images-to-dockerhub.outputs.build-image-result != 'success' || needs.build-windows-artifacts.outputs.build-windows-result != 'success' || needs.build-macos-artifacts.outputs.build-macos-result != 'success' }} + with: + payload: | + {"text": "GreptimeDB's release version ${{ needs.allocate-runners.outputs.version }} has failed, please check 'https://github.com/GreptimeTeam/greptimedb/actions/workflows/release.yml'."}