-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (57 loc) · 2.19 KB
/
concierge-to-slack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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