Enterprise-CMCS/macpro-appian-connector

View on GitHub
.github/workflows/running-stage-notifier.yml

Summary

Maintainability
Test Coverage
name: Running Stage Notifier

on:
  schedule:
    - cron: "30 20 * * 1-5"
  workflow_dispatch:

jobs:
  list-running-stages:
    name: List Running Stages
    runs-on: ubuntu-20.04

    permissions:
      id-token: write
      contents: read

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - uses: ./.github/actions/setup

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
          aws-region: us-east-1
          role-duration-seconds: 10800

      - name: Get a list of running stages
        id: runningStages
        run: |
          runningStages=`run listRunningStages | grep "runningStages="`
          echo $runningStages >> $GITHUB_OUTPUT

      - name: Slack Notification - notify of currently running stages
        uses: rtCamp/action-slack-notify@v2
        if: env.SLACK_WEBHOOK != '' && steps.runningStages.outputs.runningStages != ''
        env:
          SLACK_MSG_AUTHOR: ${{ github.repository }}
          SLACK_COLOR: ${{job.status}}
          SLACK_ICON: https://github.com/${{ github.repository_owner }}.png?size=48
          SLACK_TITLE: Currently Running Stages
          SLACK_MESSAGE: ${{ steps.runningStages.outputs.runningStages }}
          SLACK_USERNAME: ${{ github.repository }} - ${{ github.workflow }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
          MSG_MINIMAL: true

      - name: Slack Notification - notify of failure reporting on running stages
        uses: rtCamp/action-slack-notify@v2
        if: env.SLACK_WEBHOOK != '' && failure()
        env:
          SLACK_MSG_AUTHOR: ${{ github.repository }}
          SLACK_COLOR: ${{job.status}}
          SLACK_ICON: https://github.com/${{ github.repository_owner }}.png?size=48
          SLACK_TITLE: Failure retrieving currently running stages
          SLACK_MESSAGE: Failure retrieving currently running stages
          SLACK_USERNAME: ${{ github.repository }} - ${{ github.workflow }}
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
          MSG_MINIMAL: true