Reminders #72
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: Reminders | |
on: | |
schedule: | |
- cron: "30 8 * * MON-FRI" # Every weekday at 08:30 UTC | |
workflow_dispatch: | |
jobs: | |
pending-deployments: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get pending deployments | |
id: runs | |
run: echo "pending=$(gh run list --workflow pipeline.yml --branch main --status waiting --json displayTitle,url)" | tee -a "$GITHUB_OUTPUT" | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Transform results into Slack message | |
id: transform | |
if: steps.runs.outputs.pending != '[]' | |
shell: bash | |
run: | | |
echo "result=$(echo "$pending_runs" | jq -rc '. | | |
{ | |
"channel": "probation-integration-notifications", | |
"text": "Review pending deployments", | |
"blocks": ([ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*⏳ Review pending deployments*" | |
} | |
}, | |
{ | |
"type": "context", | |
"elements": [ | |
{ | |
"type": "mrkdwn", | |
"text": "> There are production deployments waiting for approval. Approve them to unblock the pipeline." | |
} | |
] | |
} | |
] + | |
(. | map({ | |
"type": "section", | |
"text": { | |
"text": ("• " + .displayTitle), | |
"type": "plain_text" | |
}, | |
"accessory": { | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": "🔎 Review" | |
}, | |
"url": .url | |
} | |
}))) | |
}')" | tee -a "$GITHUB_OUTPUT" | |
env: | |
pending_runs: ${{ steps.runs.outputs.pending }} | |
- name: Send message to Slack | |
if: steps.runs.outputs.pending != '[]' | |
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
payload: ${{ steps.transform.outputs.result }} |