Skip to content

Post Concierge to Slack #27

Post Concierge to Slack

Post Concierge to Slack #27

name: Post Concierge to Slack
on:
schedule:
# Run 8am UTC every weekday [Currently 9am BST]
- cron: "0 8 * * 1-5"
workflow_dispatch:
jobs:
post-to-slack:
runs-on: ubuntu-latest
steps:
- name: Get current date in format like Mon 1 Jan 24
id: date
run: echo "date=$(date +'%a %-d %b %y')" >> $GITHUB_OUTPUT
# Get Sheet
- name: gsheet.action
uses: jroehl/gsheet.action@v2.1.1
id: sheet
with:
spreadsheetId: ${{ secrets.CONCIERGE_ROTA_GOOGLE_SHEET_ID }}
commands: |
[
{ "command": "getData", "args": { "range": "'Probation Rota'!A1:Z100" } }
]
env:
GSHEET_CLIENT_EMAIL: ${{ secrets.GSHEET_CLIENT_EMAIL }}
GSHEET_PRIVATE_KEY: ${{ secrets.GSHEET_PRIVATE_KEY }}
- name: Extract required cell(s)
id: extract
env:
# the output of the action can be found in ${{ steps.update_worksheet.outputs.results }}
RESULTS: ${{ steps.sheet.outputs.results }}
run: |
# get todays column
col=$(echo "$RESULTS" | jq -r '.results[0].result.formatted[0] | to_entries | map(select(.value == "${{ steps.date.outputs.date }}")) | .[].key')
# echo "$col"
# get name of today's concierge
concierge=$(echo "$RESULTS" | jq -r --arg col "$col" '.results[0].result.formatted[1][$col]')
# echo "$concierge"
echo "TODAY_CONCIERGE=$concierge" >> $GITHUB_OUTPUT
- name: Slack notification
uses: slackapi/slack-github-action@v1.27.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Concierge today is :drum_roll:... \n\n*:tada: ${{ steps.extract.outputs.TODAY_CONCIERGE }} *\n\n Please respond with :white_check_mark: to confirm"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.PROBATION_MIGRATIONS_SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK