slack-notify
is a command and GitHub Action to link events in your Google Calendar to Slack.
slack-notify
does the following
- Retrieve events from Google Calendar
- Post the retrieved events to Slack
- The message to post on Slack is customizable
$ slack-notify \
-credentials ${GOOGLE_CREDENTIALS} \
-calendar-id ${GOOGLE_CALENDAR_ID} \
-slack-token ${SLACK_TOKEN} \
-slack-channel-id ${SLACK_CHANNEL_ID} \
-location Asia/Tokyo \
-message "Here is an update on today's event." \
-alternative-message "There are no events today."
# usage
$ slack-notify -h
Usage of slack-notify:
-alternative-message string
Specify alternative message
-calendar-id string
Specify Google Calendar ID
-credentials string
Specify credentials
-credentials-file string
Specify credentials file
-dry-run
Specify dry-run
-event-filter-regexp string
Specify event filter regexp (default ".")
-location string
Specify Location (default "UTC")
-message string
Specify message
-message-template-file string
Specify custom message template file
-slack-channel-id string
Specify Slack Channel ID
-slack-token string
Specify Slack Access Token
-target-date string
Specify targetDate date. e.g. 2020-01-01
-timeout duration
Specify timeout (default 15m0s)
-v Show version
-webhook string
Specify Slack Webhook URL
By default, the message posted to Slack uses the following template. Please refer to text/template for the template.
{{.Msg}}
{{range .Events -}}
• {{.Summary}}
{{end}}`
The actual message posted to Slack will be as follows.
Announcing today's events.
• A certain event
• Another event
• Yet another event
The data passed to the template is a structure like the following.
type EventData struct {
Msg string // The message specified with -message
Events []*calendar.Event
}
To customize the message, specify the template file with -message-template-file
.
$ cat template.txt
{{.Msg}}
{{range $i, $v := .Events -}}
{{$i}}. {{$v.Summary}}
{{end}}
$ slack-notify \
-message-template-file template.txt \
# Omitted
The actual message posted to Slack will be as follows.
Announcing today's events.
0. A certain event
1. Another event
2. Yet another event
$ go install github.com/ebc-2in2crc/slack-notify/cmd/slack-notify@latest
Download from the following URL.
You can also use Homebrew.
$ brew install ebc-2in2crc/tap/slack-notify
このアクションはインストールのみを実行します。
The action ebc-2in2crc/slack-notify@v0
installs the slack-notify binary for Linux in /usr/local/bin
.
This action only performs the installation.
jobs:
slack-notify:
name: slack-notify
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install slack-notify
uses: ebc-2in2crc/slack-notify@v0
- name: Notify
run: |-
slack-notify -v
- Fork this repository
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Rebase your local changes against the master branch
- Run test suite with the
make test
command and confirm that it passes - Run
make fmt
andmake lint
- Create new Pull Request