diff --git a/.github/workflows/test-report-deployment-status-to-slack.yml b/.github/workflows/test-report-deployment-status-to-slack.yml index 5d65ba67..345c2066 100644 --- a/.github/workflows/test-report-deployment-status-to-slack.yml +++ b/.github/workflows/test-report-deployment-status-to-slack.yml @@ -7,6 +7,22 @@ on: - ".github/workflows/test-report-deployment-status-to-slack.yml" jobs: + test-report-start: + name: Test Slack report failure + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + - uses: ./report-deployment-status-to-slack + with: + project: Server + environment: US QA Cloud + tag: test-workflow-start + slack-channel: devops-alerts-test + event: 'start' + url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }} + AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + test-report: name: Test Slack report runs-on: ubuntu-22.04 @@ -15,10 +31,12 @@ jobs: - uses: ./report-deployment-status-to-slack with: + project: Server environment: US QA Cloud - tag: test-workflow - slack-channel: devops-alerts - failure: false + tag: test-workflow-success + slack-channel: devops-alerts-test + event: 'success' + url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }} AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} test-report-failure: @@ -32,7 +50,8 @@ jobs: project: Server environment: US QA Cloud tag: test-workflow-failure - slack-channel: devops-alerts - failure: true + slack-channel: devops-alerts-test + event: 'failure' + url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }} AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} diff --git a/report-deployment-status-to-slack/action.yml b/report-deployment-status-to-slack/action.yml index 555d17bd..50f2dd3e 100644 --- a/report-deployment-status-to-slack/action.yml +++ b/report-deployment-status-to-slack/action.yml @@ -13,10 +13,13 @@ inputs: description: "The name of the slack channel." required: true default: team-eng-qa-devops - failure: - description: "If message should be a failure message" + event: + description: "Deployment event type. Possible values are start, success, or failure." + required: true + url: + description: "Deployment event type. Possible values are start, success, or failure." required: false - default: 'false' + default: ${{ github.event.deployment_status.target_url }} AZURE_KV_CI_SERVICE_PRINCIPAL: description: "The service principal used to authenticate to Azure." required: true @@ -25,7 +28,7 @@ runs: using: "composite" steps: - name: Login to Azure - Prod Subscription - uses: Azure/login@4c88f01b0e3a5600e08a37889921afd060f75cf0 # v1.5.0 + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 with: creds: ${{ inputs.AZURE_KV_CI_SERVICE_PRINCIPAL }} @@ -36,20 +39,29 @@ runs: keyvault: bitwarden-ci secrets: "slack-bot-token" + - name: Post to a Slack channel on start + if: ${{ inputs.event == 'start' }} + uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 + with: + channel-id: ${{ inputs.slack-channel }} + slack-message: ":loading: Updating ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\n ${{ inputs.url }}." + env: + SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }} + - name: Post to a Slack channel on success - if: ${{ inputs.failure == 'false' }} + if: ${{ inputs.event == 'success' }} uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 with: channel-id: ${{ inputs.slack-channel }} - slack-message: ":white_check_mark: Updated ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}." + slack-message: ":white_check_mark: Updated ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\n ${{ inputs.url }}." env: SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }} - name: Post to a Slack channel on failure - if: ${{ inputs.failure == 'true' }} + if: ${{ inputs.event == 'failure' }} uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 with: channel-id: ${{ inputs.slack-channel }} - slack-message: ":x: Failed to update ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\nPlease retry or contact @devops team." + slack-message: ":x: Failed to update ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\n ${{ inputs.url }}.\nPlease retry or contact @devops team." env: SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }} \ No newline at end of file