Skip to content

Commit 94b6419

Browse files
committed
Reading out enterprise and slug
1 parent 4a85e4b commit 94b6419

File tree

4 files changed

+112
-3
lines changed

4 files changed

+112
-3
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,66 @@ GitHub Action that can create various list of users from GitHub
44

55
* All known GitHub users with their linked SSO accounts
66
* List of all external collaborators and who invited them
7+
8+
## User list
9+
10+
Creates a markdown file with the list of all users of the enterprise.
11+
12+
### Example
13+
14+
> # GitHub Enterprise Users
15+
> | # | GitHub Login | E-Mail |
16+
> | --- |------------------------------------------------------------------|-------------------------|
17+
> | 1 | [foo](https://github.com/enterprises/prodyna/people/fassmus/sso) | [email protected] |
18+
> | 2 | [bar](https://github.com/enterprises/prodyna/people/dkrizic/sso) | [email protected] |
19+
20+
### Using
21+
22+
This action can be used in a workflow like this:
23+
24+
```yaml
25+
ame: Create Overview
26+
27+
on:
28+
workflow_dispatch:
29+
# Every day at 07:00
30+
schedule:
31+
- cron: '0 7 * * *'
32+
33+
jobs:
34+
create-overview:
35+
runs-on: ubuntu-latest
36+
steps:
37+
# Checkout the existing content of thre repository
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
# Create directory profile if it does not exist
42+
- name: Create profile directory
43+
run: mkdir -p profile
44+
45+
# Run the deployment overview action
46+
- name: Github users
47+
uses: prodyna/[email protected]
48+
with:
49+
# The action to run
50+
action: userlist
51+
# The GitHub Enterprise to query for repositories
52+
enterprise: octocat
53+
# The GitHub Token to use for authentication
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
# The template file to use for rendering the result
56+
template-file: template/userlist.tpl
57+
# The markdown file to write the result to
58+
markdown-file: USERS.md
59+
# Verbosity level, 0=info, 1=debug
60+
verbose: 1
61+
62+
# Push the generated files
63+
- name: Commit changes
64+
run: |
65+
git config --local user.email "[email protected]"
66+
git config --local user.name "Deployment Overview"
67+
git add profile
68+
git commit -m "Add/update deployment overview"
69+
```

action.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'GitHub Users'
2+
description: 'GitHub Action that creates list of enterprise users or allows automatic invitation of users'
3+
4+
inputs:
5+
action:
6+
description: 'The action to perform, currently supported: userlist'
7+
required: true
8+
enterprise:
9+
description: 'The GitHub Enterprise to query for repositories'
10+
required: true
11+
github-token:
12+
description: 'The GitHub Token to use for authentication'
13+
required: true
14+
template-file:
15+
description: 'The template file to use for rendering the result'
16+
required: false
17+
default: '/template/userlist.tpl'
18+
markdown-file:
19+
description: 'The markdown file to write the result to'
20+
required: false
21+
default: 'USERS.md'
22+
verbose:
23+
description: 'The verbosity level'
24+
required: false
25+
default: 1
26+
runs:
27+
using: 'docker'
28+
image: 'docker://ghcr.io/prodyna/github-users:v0.1'
29+
env:
30+
ACTION: ${{ inputs.action }}
31+
ENTERPRISE: ${{ inputs.enterprise }}
32+
GITHUB_TOKEN: ${{ inputs.github-token }}
33+
TEMPLATE_FILE: ${{ inputs.template-file }}
34+
MARKDOWN_FILE: ${{ inputs.markdown-file }}
35+
VERBOSE: ${{ inputs.verbose }}

template/userlist.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# GitHub Enterprise Users
1+
# GitHub Enterprise Users for {{ .Enterprise.Name }}
22

33
| # | GitHub Login | E-Mail |
44
| --- | --- | --- |
5-
{{ range .Users }} | {{ .Number }} | [{{ .Login }}](https://github.com/enterprises/prodyna/people/{{ .Login }}/sso) | {{ .Email }} |
5+
{{ range .Users }} | {{ .Number }} | [{{ .Login }}](https://github.com/enterprises/{{ $.Enterprise.Slug }}/people/{{ .Login }}/sso) | {{ .Email }} |
66
{{end}}

userlist/userlist.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ type UserListConfig struct {
2424
}
2525

2626
type UserList struct {
27-
Users []User
27+
Enterprise Enterprise
28+
Users []User
29+
}
30+
31+
type Enterprise struct {
32+
Slug string
33+
Name string
2834
}
2935

3036
type User struct {
@@ -157,6 +163,11 @@ func (c *UserListConfig) Load() error {
157163
slog.ErrorContext(ctx, "Unable to query", "error", err)
158164
}
159165

166+
c.userList.Enterprise = Enterprise{
167+
Slug: query.Enterprise.Slug,
168+
Name: query.Enterprise.Name,
169+
}
170+
160171
for i, e := range query.Enterprise.OwnerInfo.SamlIdentityProvider.ExternalIdentities.Edges {
161172
u := User{
162173
Number: i + 1,

0 commit comments

Comments
 (0)