Actions Usage Alert #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Actions Usage Alert | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' | |
env: | |
ORG: octodemo | |
GITHUB_TOKEN: ${{ secrets.AUSTEN_PAT }} | |
# The threshold for the total minutes used by the Actions in the organization | |
TOTAL_MINS_USED_ALERT_THRESHOLD: 50000 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "actions-billing=$(gh api /orgs/$ORG/settings/billing/actions)" >> "$GITHUB_OUTPUT" | |
id: api | |
- if: fromJson(steps.api.outputs.actions-billing).total_minutes_used >= env.TOTAL_MINS_USED_ALERT_THRESHOLD | |
uses: slackapi/[email protected] | |
with: | |
# Slack channel id, channel name, or user id to post message. | |
# See also: https://api.slack.com/methods/chat.postMessage#channels | |
# You can pass in multiple channels to post to by providing a comma-delimited list of channel IDs. | |
channel-id: 'CHANNEL_ID,ANOTHER_CHANNEL_ID' | |
# For posting a simple plain text message | |
slack-message: "The total minutes used by the Actions in the $ORG organization has exceeded the threshold of $TOTAL_MINS_USED_ALERT_THRESHOLD. The current total minutes used is ${{fromJson(steps.api.outputs.actions-billing).total_minutes_used}}." | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |