Migrate slack notifications to GChat (2nd attempt)

Closes gh-15503
This commit is contained in:
Steve Riesenberg 2024-08-20 16:44:33 -05:00
parent 097c927d8d
commit 92809cef01
No known key found for this signature in database
GPG Key ID: 3D0169B18AB8F0A9
5 changed files with 48 additions and 55 deletions

View File

@ -9,7 +9,6 @@ on:
workflow_dispatch: # Manual trigger workflow_dispatch: # Manual trigger
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
COMMIT_OWNER: ${{ github.event.pusher.name }} COMMIT_OWNER: ${{ github.event.pusher.name }}
COMMIT_SHA: ${{ github.sha }} COMMIT_SHA: ${{ github.sha }}
@ -209,26 +208,11 @@ jobs:
run: | run: |
echo "Tagging and publishing $REPO@$VERSION release on GitHub." echo "Tagging and publishing $REPO@$VERSION release on GitHub."
./gradlew createGitHubRelease -PnextVersion=$VERSION -Pbranch=$BRANCH -PcreateRelease=true -PgitHubAccessToken=$TOKEN ./gradlew createGitHubRelease -PnextVersion=$VERSION -Pbranch=$BRANCH -PcreateRelease=true -PgitHubAccessToken=$TOKEN
- name: Announce Release on Slack - name: Announce Release on GChat
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"
}
}
]
}
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_SLACK_WEBHOOK_URL }} WEBHOOK_URL: ${{ secrets.SPRING_RELEASE_GCHAT_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK 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 - name: Setup git config
run: | run: |
git config user.name 'github-actions[bot]' git config user.name 'github-actions[bot]'
@ -260,20 +244,13 @@ jobs:
distribution: 'adopt' distribution: 'adopt'
- name: Schedule next release (if not already scheduled) - name: Schedule next release (if not already scheduled)
run: ./gradlew scheduleNextRelease -PnextVersion=$VERSION -PgitHubAccessToken=$TOKEN run: ./gradlew scheduleNextRelease -PnextVersion=$VERSION -PgitHubAccessToken=$TOKEN
notify_result: send-notification:
name: Check for failures name: Send Notification
needs: [perform_release, perform_post_release] needs: [ perform_release, perform_post_release ]
if: failure() if: ${{ failure() || cancelled() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
actions: read
steps: steps:
- name: Send Slack message - name: Send Notification
# Workaround while waiting for Gamesight/slack-workflow-status#38 to be fixed uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1
# See https://github.com/Gamesight/slack-workflow-status/issues/38
uses: sjohnr/slack-workflow-status@v1-beta
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
channel: '#spring-security-ci'
name: 'CI Notifier'

View File

@ -8,6 +8,7 @@ permissions: write-all
jobs: jobs:
merge-dependabot-pr: merge-dependabot-pr:
name: Merge Dependabot PR
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'spring-projects/spring-security' }} if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'spring-projects/spring-security' }}
steps: steps:
@ -50,3 +51,13 @@ jobs:
run: gh pr merge ${{ github.event.pull_request.number }} --auto --rebase run: gh pr merge ${{ github.event.pull_request.number }} --auto --rebase
env: env:
GH_TOKEN: ${{ secrets.GH_ACTIONS_REPO_TOKEN }} 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 }}

View File

@ -23,18 +23,13 @@ jobs:
export TOOL_VERSION=0.1.1 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" 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 java -cp "spring-release-train-tools-$TOOL_VERSION.jar" io.spring.releasetrain.CheckMilestoneDueOnMain --dueOn "$DUE_ON" --expectedDayOfWeek MONDAY --expectedMondayCount 3
notify_result: send-notification:
name: Check for failures name: Send Notification
needs: [spring-releasetrain-checks] needs: [ spring-releasetrain-checks ]
if: failure() if: ${{ failure() || cancelled() }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
actions: read
steps: steps:
- name: Send Slack message - name: Send Notification
uses: Gamesight/slack-workflow-status@v1.3.0 uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
channel: '#spring-security-ci'
name: 'CI Notifier'

View File

@ -42,3 +42,13 @@ jobs:
name: docs name: docs
path: docs/build/site path: docs/build/site
overwrite: true 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 }}

View File

@ -4,7 +4,6 @@ on:
workflow_dispatch: # Manual trigger only. Triggered by release-scheduler.yml on main. workflow_dispatch: # Manual trigger only. Triggered by release-scheduler.yml on main.
env: env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
permissions: permissions:
@ -58,12 +57,13 @@ jobs:
git tag $updatedVersion git tag $updatedVersion
git push git push
git push origin $updatedVersion git push origin $updatedVersion
- id: send-slack-notification send-notification:
name: Send Slack message name: Send Notification
if: failure() needs: [ update_scheduled_release_version ]
uses: Gamesight/slack-workflow-status@v1.3.0 if: ${{ failure() || cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Send Notification
uses: spring-io/spring-security-release-tools/.github/actions/send-notification@v1
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} webhook-url: ${{ secrets.SPRING_SECURITY_CI_GCHAT_WEBHOOK_URL }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
channel: '#spring-security-ci'
name: 'CI Notifier'