-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: showcase updated use cases in example workflows (#376)
Co-authored-by: Luke Russell <31357343+lukegalbraithrussell@users.noreply.github.com>
- Loading branch information
1 parent
6a5a811
commit e6e5eb1
Showing
27 changed files
with
785 additions
and
132 deletions.
There are no files selected for viewing
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
16 changes: 0 additions & 16 deletions
16
example-workflows/Technique_1_Slack_Workflow_Builder/JSON_payload.yml
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
example-workflows/Technique_1_Slack_Workflow_Builder/JSON_payload_from_file.yml
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
example-workflows/Technique_1_Slack_Workflow_Builder/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Technique 1: Slack Workflow Builder | ||
|
||
> :memo: This technique uses Workflow Builder, which requires | ||
> [a Slack paid plan][plans]. | ||
This technique sends data to Slack using a webhook to start a workflow created | ||
using Slack [Workflow Builder][wfb]. | ||
|
||
## Setup | ||
|
||
The Slack app manifest included with each example showcases steps of a workflow | ||
in [Workflow Builder][wfb] along with the [webhook trigger][triggers] inputs. | ||
|
||
For details on how to setup this technique in GitHub Actions, read the | ||
[`README.md`][setup]. | ||
|
||
## Example workflows | ||
|
||
1. [**Format generated files**](#format-generated-files): Message outputs from | ||
prior steps. | ||
2. [**Post release announcements**](#post-release-announcements): Share releases | ||
to a channel. | ||
3. [**Update a channel topic**](#update-a-channel-topic): Highlight the current | ||
build status. | ||
|
||
### Format generated files | ||
|
||
Convert build outputs from earlier GitHub Action steps into a Slack message. | ||
|
||
This example uses data from a payload file to [send a message][send_message] to | ||
a hardcoded channel. | ||
|
||
**Related files**: | ||
|
||
- [`builds.data.json`](./builds.data.json): Payload file being sent. | ||
- [`builds.gha.yml`](./builds.gha.yml): GitHub Actions workflow. | ||
- [`builds.manifest.json`](./builds.manifest.json): Slack app manifest. | ||
- [`builds.trigger.json`](./builds.trigger.json): Slack webhook trigger. | ||
|
||
### Post release announcements | ||
|
||
Select a channel to post news about the most recent release to. | ||
|
||
This example uses [Slack functions][functions] and inline inputs to do the | ||
following: | ||
|
||
1. Open a form to select a channel. | ||
2. Send a message to the selected channel. | ||
3. React with a `:tada:` emoji. | ||
|
||
**Related files**: | ||
|
||
- [`announcements.gha.yml`](./announcements.gha.yml): GitHub Actions workflow. | ||
- [`announcements.manifest.json`](./announcements.manifest.json): Slack app | ||
manifest. | ||
- [`announcements.trigger.json`](./announcements.trigger.json): Slack webhook | ||
trigger. | ||
|
||
### Update a channel topic | ||
|
||
Show the latest commit status in the header of a channel. | ||
|
||
This example uses the default GitHub event [context][event-context] and | ||
[payload][event-payload] to [update a channel topic][update_channel_topic]. | ||
|
||
**Related files**: | ||
|
||
- [`topic.gha.yml`](./topic.gha.yml): GitHub Actions workflow. | ||
- [`topic.manifest.json`](./topic.manifest.json): Slack app manifest. | ||
- [`topic.trigger.json`](./topic.trigger.json): Slack webhook trigger. | ||
|
||
[event-context]: https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L6 | ||
[event-payload]: https://docs.github.com/en/webhooks/webhook-events-and-payloads | ||
[functions]: https://api.slack.com/automation/functions | ||
[giphy]: https://giphy.com | ||
[send_message]: https://api.slack.com/reference/functions/send_message | ||
[plans]: https://slack.com/pricing | ||
[setup]: https://github.com/slackapi/slack-github-action/blob/main/README.md#technique-1-slack-workflow-builder | ||
[triggers]: https://api.slack.com/automation/triggers/webhook | ||
[update_channel_topic]: https://api.slack.com/reference/functions/update_channel_topic | ||
[wfb]: https://slack.com/features/workflow-automation |
22 changes: 22 additions & 0 deletions
22
example-workflows/Technique_1_Slack_Workflow_Builder/announcements.gha.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
|
||
name: Post release announcements | ||
on: | ||
release: | ||
types: | ||
- published | ||
jobs: | ||
run: | ||
name: Share recent changes with a channel | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Draft with these release notes details | ||
uses: slackapi/slack-github-action@v2.0.0 | ||
with: | ||
webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
webhook-type: webhook-trigger | ||
payload: | | ||
"draft_channel": "${{ secrets.SLACK_CHANNEL_ID }}", | ||
"release_notes": ${{ toJSON(github.event.release.body) }}, | ||
"release_repository": "${{ github.repository }}", | ||
"release_version": "${{ github.event.release.tag_name }}", |
113 changes: 113 additions & 0 deletions
113
example-workflows/Technique_1_Slack_Workflow_Builder/announcements.manifest.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"_metadata": { | ||
"major_version": 2 | ||
}, | ||
"display_information": { | ||
"name": "Slack GitHub Actions Releaser", | ||
"description": "Sharing the latest news in channel" | ||
}, | ||
"features": { | ||
"app_home": { | ||
"messages_tab_enabled": false | ||
}, | ||
"bot_user": { | ||
"display_name": "Slack GitHub Actions Releaser" | ||
} | ||
}, | ||
"oauth_config": { | ||
"scopes": { | ||
"bot": ["chat:write", "chat:write.public", "reactions:write"] | ||
} | ||
}, | ||
"settings": { | ||
"org_deploy_enabled": true | ||
}, | ||
"workflows": { | ||
"release_announcement": { | ||
"title": "Release announcement", | ||
"description": "Share excitement around the latest changes", | ||
"input_parameters": { | ||
"properties": { | ||
"draft_channel": { | ||
"type": "slack#/types/channel_id" | ||
}, | ||
"release_notes": { | ||
"type": "string" | ||
}, | ||
"release_repository": { | ||
"type": "string" | ||
}, | ||
"release_version": { | ||
"type": "string" | ||
} | ||
}, | ||
"required": [ | ||
"draft_channel", | ||
"release_notes", | ||
"release_repository", | ||
"release_version" | ||
] | ||
}, | ||
"steps": [ | ||
{ | ||
"id": "0", | ||
"function_id": "slack#/functions/send_message", | ||
"inputs": { | ||
"channel_id": "{{inputs.draft_channel}}", | ||
"message": "A new release of <https://github.com/{{inputs.release_repository}}/releases/tag/{{inputs.release_version}}|{{inputs.release_repository}}@{{inputs.release_version}}> was tagged! :rocket:", | ||
"interactive_blocks": [ | ||
{ | ||
"type": "actions", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Share" | ||
}, | ||
"action_id": "share" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"id": "1", | ||
"function_id": "slack#/functions/open_form", | ||
"inputs": { | ||
"title": "Share the release notes", | ||
"interactivity": "{{steps.0.interactivity}}", | ||
"submit_label": "Share", | ||
"fields": { | ||
"elements": [ | ||
{ | ||
"name": "announcement_channel", | ||
"title": "Select an announcements channel", | ||
"type": "slack#/types/channel_id" | ||
} | ||
], | ||
"required": ["announcement_channel"] | ||
} | ||
} | ||
}, | ||
{ | ||
"id": "2", | ||
"function_id": "slack#/functions/send_message", | ||
"inputs": { | ||
"channel_id": "{{steps.1.fields.announcement_channel}}", | ||
"message": "A new release of <https://github.com/{{inputs.release_repository}}/releases/tag/{{inputs.release_version}}|{{inputs.release_repository}}@{{inputs.release_version}}> was tagged! :rocket:\n```{{inputs.release_notes}}```" | ||
} | ||
}, | ||
{ | ||
"id": "3", | ||
"function_id": "slack#/functions/add_reaction", | ||
"inputs": { | ||
"message_context": "{{steps.2.message_context}}", | ||
"emoji": "tada" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
example-workflows/Technique_1_Slack_Workflow_Builder/announcements.trigger.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"type": "webhook", | ||
"name": "Release webhook", | ||
"description": "Share the most recent changes", | ||
"workflow": "#/workflows/release_announcement", | ||
"inputs": { | ||
"draft_channel": { | ||
"value": "{{data.draft_channel}}" | ||
}, | ||
"release_notes": { | ||
"value": "{{data.release_notes}}" | ||
}, | ||
"release_repository": { | ||
"value": "{{data.release_repository}}" | ||
}, | ||
"release_version": { | ||
"value": "{{data.release_version}}" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
example-workflows/Technique_1_Slack_Workflow_Builder/builds.data.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"status": "done", | ||
"task": "Downstream staging rollout", | ||
"errors": "", | ||
"runner": "github-actions" | ||
} |
23 changes: 23 additions & 0 deletions
23
example-workflows/Technique_1_Slack_Workflow_Builder/builds.gha.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
|
||
name: Format generated files | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
run: | ||
name: Write structured data as a message | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Start the Slack workflow | ||
uses: slackapi/slack-github-action@v2.0.0 | ||
with: | ||
payload-file-path: "./example-workflows/Technique_1_Slack_Workflow_Builder/builds.data.json" | ||
webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
webhook-type: webhook-trigger |
Oops, something went wrong.