From 92809cef01730e6b2f581a7c6208a24b7a696d7d Mon Sep 17 00:00:00 2001 From: Steve Riesenberg <5248162+sjohnr@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:44:33 -0500 Subject: [PATCH] Migrate slack notifications to GChat (2nd attempt) Closes gh-15503 --- .../continuous-integration-workflow.yml | 45 +++++-------------- .github/workflows/merge-dependabot-pr.yml | 11 +++++ .../milestone-spring-releasetrain.yml | 19 +++----- .github/workflows/pr-build-workflow.yml | 10 +++++ .../update-scheduled-release-version.yml | 18 ++++---- 5 files changed, 48 insertions(+), 55 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 2bc4774549..c2c4554204 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -9,7 +9,6 @@ on: workflow_dispatch: # Manual trigger env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} COMMIT_OWNER: ${{ github.event.pusher.name }} COMMIT_SHA: ${{ github.sha }} @@ -209,26 +208,11 @@ jobs: run: | echo "Tagging and publishing $REPO@$VERSION release on GitHub." ./gradlew createGitHubRelease -PnextVersion=$VERSION -Pbranch=$BRANCH -PcreateRelease=true -PgitHubAccessToken=$TOKEN - - name: Announce Release on Slack - id: spring-security-announcing - uses: slackapi/slack-github-action@v1.26.0 - with: - payload: | - { - "text": "spring-security-announcing `${{ env.VERSION }}` is available now", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "spring-security-announcing `${{ env.VERSION }}` is available now" - } - } - ] - } + - name: Announce Release on GChat env: - SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }} + run: | + curl -X POST '${{ env.WEBHOOK_URL }}' -H 'Content-Type: application/json' -d '{ "text": "spring-security-announcing `${{ env.VERSION }}` is available now" }' || true - name: Setup git config run: | git config user.name 'github-actions[bot]' @@ -260,20 +244,13 @@ jobs: distribution: 'adopt' - name: Schedule next release (if not already scheduled) run: ./gradlew scheduleNextRelease -PnextVersion=$VERSION -PgitHubAccessToken=$TOKEN - notify_result: - name: Check for failures - needs: [perform_release, perform_post_release] - if: failure() + send-notification: + name: Send Notification + needs: [ perform_release, perform_post_release ] + if: ${{ failure() || cancelled() }} runs-on: ubuntu-latest - permissions: - actions: read steps: - - name: Send Slack message - # Workaround while waiting for Gamesight/slack-workflow-status#38 to be fixed - # See https://github.com/Gamesight/slack-workflow-status/issues/38 - uses: sjohnr/slack-workflow-status@v1-beta + - name: Send Notification + uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} - channel: '#spring-security-ci' - name: 'CI Notifier' + webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} diff --git a/.github/workflows/merge-dependabot-pr.yml b/.github/workflows/merge-dependabot-pr.yml index 9c614bc866..4f2168eb3b 100644 --- a/.github/workflows/merge-dependabot-pr.yml +++ b/.github/workflows/merge-dependabot-pr.yml @@ -8,6 +8,7 @@ permissions: write-all jobs: merge-dependabot-pr: + name: Merge Dependabot PR runs-on: ubuntu-latest if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'spring-projects/spring-security' }} steps: @@ -50,3 +51,13 @@ jobs: run: gh pr merge ${{ github.event.pull_request.number }} --auto --rebase env: GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} + send-notification: + name: Send Notification + needs: [ merge-dependabot-pr ] + if: ${{ failure() || cancelled() }} + runs-on: ubuntu-latest + steps: + - name: Send Notification + uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1 + with: + webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} diff --git a/.github/workflows/milestone-spring-releasetrain.yml b/.github/workflows/milestone-spring-releasetrain.yml index 87d1ab287e..0602ae8e73 100644 --- a/.github/workflows/milestone-spring-releasetrain.yml +++ b/.github/workflows/milestone-spring-releasetrain.yml @@ -23,18 +23,13 @@ jobs: export TOOL_VERSION=0.1.1 wget "https://repo.maven.apache.org/maven2/io/spring/releasetrain/spring-release-train-tools/$TOOL_VERSION/spring-release-train-tools-$TOOL_VERSION.jar" java -cp "spring-release-train-tools-$TOOL_VERSION.jar" io.spring.releasetrain.CheckMilestoneDueOnMain --dueOn "$DUE_ON" --expectedDayOfWeek MONDAY --expectedMondayCount 3 - notify_result: - name: Check for failures - needs: [spring-releasetrain-checks] - if: failure() + send-notification: + name: Send Notification + needs: [ spring-releasetrain-checks ] + if: ${{ failure() || cancelled() }} runs-on: ubuntu-latest - permissions: - actions: read steps: - - name: Send Slack message - uses: Gamesight/slack-workflow-status@v1.3.0 + - name: Send Notification + uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} - channel: '#spring-security-ci' - name: 'CI Notifier' + webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} diff --git a/.github/workflows/pr-build-workflow.yml b/.github/workflows/pr-build-workflow.yml index c6f0f9ba78..6c835f010e 100644 --- a/.github/workflows/pr-build-workflow.yml +++ b/.github/workflows/pr-build-workflow.yml @@ -42,3 +42,13 @@ jobs: name: docs path: docs/build/site overwrite: true + send-notification: + name: Send Notification + needs: [ build, generate-docs ] + if: ${{ failure() && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'spring-projects/spring-security' }} + runs-on: ubuntu-latest + steps: + - name: Send Notification + uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1 + with: + webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }} diff --git a/.github/workflows/update-scheduled-release-version.yml b/.github/workflows/update-scheduled-release-version.yml index 0453acee62..b63cae3bb0 100644 --- a/.github/workflows/update-scheduled-release-version.yml +++ b/.github/workflows/update-scheduled-release-version.yml @@ -4,7 +4,6 @@ on: workflow_dispatch: # Manual trigger only. Triggered by release-scheduler.yml on main. env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} permissions: @@ -58,12 +57,13 @@ jobs: git tag $updatedVersion git push git push origin $updatedVersion - - id: send-slack-notification - name: Send Slack message - if: failure() - uses: Gamesight/slack-workflow-status@v1.3.0 + send-notification: + name: Send Notification + needs: [ update_scheduled_release_version ] + if: ${{ failure() || cancelled() }} + runs-on: ubuntu-latest + steps: + - name: Send Notification + uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1 with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} - channel: '#spring-security-ci' - name: 'CI Notifier' + webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}