You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This action generates a mapping of Slack user details by GitHub username for use in [Slack Deploy Pipeline Notifications](../../../README.md). It intends to decouple the user mapping process, dependent on a conservatively rate limited [Slack API method](https://docs.slack.dev/reference/methods/users.list/), from the higher throughput notification action.
4
+
5
+
## Setup
6
+
7
+
### GitHub Token
8
+
9
+
A fine-grained personal access token must be configured as the default `GITHUB_TOKEN` does not include adequate permissions:
10
+
11
+
1.[Create a fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token)
12
+
2. Under **Resource owner**, select your GitHub organization
13
+
3. Under **Permissions**, select "Members" (read-only)
14
+
4.[Create a GitHub secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets) with this token, named `GH_ORG_MEMBERS_TOKEN`
15
+
16
+
### Slack Token
17
+
18
+
If you have not already provisioned a Slack Bot Token:
19
+
20
+
5.[Create a Slack App](https://api.slack.com/apps) for your workspace
21
+
6. Under **OAuth & Permissions**, add the [`users:read`](https://api.slack.com/scopes/users:read) Bot Token Scope
22
+
7. Copy the app's **Bot User OAuth Token**
23
+
8.[Create a GitHub secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets) with this token, named `SLACK_DEPLOY_BOT_TOKEN`
24
+
25
+
## Usage
26
+
27
+
In a conventional setup, the user mapping is periodically uploaded as a GitHub workflow artifact and downloaded within deploy workflows.
28
+
29
+
### Schedule Workflow
30
+
31
+
Create a [`schedule`](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#schedule) event-triggered workflow that [uploads](https://github.com/actions/upload-artifact) the generated user mapping as a `slack-deploy-user-mapping.json`[workflow artifact](https://docs.github.com/en/actions/tutorials/store-and-share-data):
github_org: your-org # replace with your GitHub organization name
52
+
53
+
- name: Write to file
54
+
run: |
55
+
cat << 'EOF' > slack-deploy-user-mapping.json
56
+
${{ steps.user-mapping.outputs.json }}
57
+
EOF
58
+
59
+
- name: Upload artifact
60
+
uses: actions/upload-artifact@v4
61
+
with:
62
+
name: slack-deploy-user-mapping
63
+
path: slack-deploy-user-mapping.json
64
+
if-no-files-found: 'error'
65
+
retention-days: 2
66
+
overwrite: true
67
+
```
68
+
69
+
### Deploy Workflow
70
+
71
+
In your deploy workflows, [download the artifact](https://github.com/dawidd6/action-download-artifact) and set the `SLACK_DEPLOY_GITHUB_USERS` environment variable before using the [Slack Deploy Pipeline Notifications](../../../README.md) action:
| `github_token` | Repository `GITHUB_TOKEN` or personal access token secret; defaults to [`github.token`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) |
108
115
| `status` | The current status of the job; defaults to [`job.status`](https://docs.github.com/en/actions/learn-github-actions/contexts#job-context) |
109
116
110
-
## Outputs
117
+
### Outputs
111
118
112
119
| output | description |
113
120
| ------ | -------------------------- |
114
121
| `ts` | Slack message timestamp ID |
122
+
123
+
## Slack User Mapping
124
+
125
+
By default, this GitHub Action attempts to [mention](https://slack.com/help/articles/205240127-Use-mentions-in-Slack) the Slack user corresponding to the GitHub actor by full name. This process depends on a conservatively rate limited [Slack API method](https://docs.slack.dev/reference/methods/users.list/); depending on your deploy throughput, it might fail and gracefully fallback to the GitHub username.
126
+
127
+
To improve reliability, the action can be provided a predefined user mapping via a `SLACK_DEPLOY_GITHUB_USERS` environment variable. The data should be an object keyed by GitHub username mapped to Slack user detail values in JSON or YAML format.
128
+
129
+
The data is conventionally JSON generated by the [Generate Slack Deploy User Mapping](./.github/actions/generate-user-mapping/README.md) GitHub Action. However, it can also be provided as inline YAML as in the example below:
0 commit comments