Skip to content

Post Concierge to Slack #38

Post Concierge to Slack

Post Concierge to Slack #38

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": "'Rota2'!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
echo $RESULTS
date_col=$(echo "$RESULTS" | jq -r '.results[0].result.formatted | to_entries | map(select(.value["(A)"] == "${{ steps.date.outputs.date }}")) | .[].key')
#echo "$date_col"
# get name of today's concierge
probation_concierge=$(echo "$RESULTS" | jq -r --arg date_col "$date_col" '.results[0].result.formatted[$date_col]["(B)"]')
dso_concierge=$(echo "$RESULTS" | jq -r --arg date_col "$date_col" '.results[0].result.formatted[$date_col]["(C)"]')
laa_concierge=$(echo "$RESULTS" | jq -r --arg date_col "$date_col" '.results[0].result.formatted[$date_col]["(D)"]')
#echo "probation_concierge=$probation_concierge" >> $GITHUB_OUTPUT
#echo "dso_concierge=$dso_concierge" >> $GITHUB_OUTPUT
#echo "laa_concierge=$laa_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 *Probation:* ${{ steps.extract.outputs.probation_concierge }} \n\n *DSO:* ${{ steps.extract.outputs.dso_concierge }} \n\n *LAA:* ${{ steps.extract.outputs.laa_concierge }} \n :tada: \n\n Please respond with :white_check_mark: to confirm"
# }
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.TEAM_MIGRATIONS_SLACK_WEBHOOK }}
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK