Skip to content

Commit 194da67

Browse files
docs: update documentation for github-org-member-manage-action
* docs: update documentation for github-org-member-manage-action * docs: update documentation for github-org-member-manage-action * docs: update documentation for github-org-member-manage-action --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent f10c9f5 commit 194da67

File tree

2 files changed

+126
-27
lines changed

2 files changed

+126
-27
lines changed

README.md

Lines changed: 111 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,124 @@
1-
# github-org-member-manage-action
1+
# GitHub Org Member Manage Action
22

3-
## Objective
3+
This GitHub Action allows you to manage your GitHub organization's memberships in a declarative way using a YAML file. This file becomes the single source of truth for your organization's members, making it easy to manage and version control your member list.
44

5-
Mange GitHub org memberships in a declarative way (.yaml).
6-
YAML will be the single source of truth for the org memberships.
5+
## Features
6+
7+
- **Declarative Membership Management:** Define your organization's members and their roles (admin or member) in a simple YAML file.
8+
- **Synchronization:** The action automatically synchronizes the members of your organization to match the state defined in your YAML file.
9+
- **Dry Run Mode:** Preview the changes that would be made without actually applying them.
10+
- **Bootstrap Your Configuration:** `write` mode helps you to create a `members.yaml` from the current state of your GitHub org members.
11+
12+
## Usage
13+
14+
To use this action in your workflow, you need to add a step that uses `codingpot/github-org-member-manage-action`.
15+
16+
### Example Workflow
17+
18+
Here is an example workflow that runs on a schedule and synchronizes the organization's members:
19+
20+
```yaml
21+
name: Manage Org Members
22+
23+
on:
24+
schedule:
25+
- cron: '0 0 * * *' # Run daily at midnight
26+
workflow_dispatch:
27+
28+
jobs:
29+
manage-members:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v3
34+
35+
- name: Manage GitHub Org Members
36+
uses: "codingpot/github-org-member-manage-action@v1"
37+
with:
38+
gh_token: ${{ secrets.GH_TOKEN }}
39+
members_filepath: 'members.yaml'
40+
mode: 'sync'
41+
```
42+
43+
### `members.yaml` format
44+
45+
The `members.yaml` file defines the members of your organization. Here is an example:
746

847
```yaml
948
# members.yaml
10-
org_name: codingpot
49+
org_name: your-org-name
1150
1251
admins:
13-
- kkweon
14-
- kkweon2
52+
- admin-user-1
53+
- admin-user-2
1554
1655
members:
17-
- deepdiver1
18-
- deepdiver2
56+
- member-user-1
57+
- member-user-2
1958
```
2059

21-
## How to use
60+
## Action Inputs
2261

23-
```yaml
24-
steps:
25-
- uses: "codingpot/github-org-member-manage-action@v1"
26-
with:
27-
gh_token: ${{ secrets.GH_TOKEN }} # (required) Needs admin:org permission
28-
members_filepath: members.yaml # (optional)
29-
dry_run: false # (optional)
30-
mode: sync # (optional) write or sync
62+
| Input | Description | Default |
63+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------- |
64+
| `gh_token` | A GitHub token with `admin:org` scope. This is required to manage organization memberships. It is recommended to use a secret to store the token. | **Required** |
65+
| `members_filepath` | The file path to the YAML file containing the list of members. This file will be the single source of truth for the organization's memberships. | `members.yaml` |
66+
| `dry_run` | If set to `true`, the action will only print the changes that would be made, without actually applying them. This is useful for testing and debugging. | `false` |
67+
| `mode` | The mode of operation for the action. There are two modes available: `sync` and `write`.<ul><li>`sync`: This mode synchronizes the organization's memberships with the state defined in the `members_filepath` file.</li><li>`write`: This mode fetches the current organization memberships and writes them to the `members_filepath` file.</li></ul> | `sync` |
68+
69+
## Development
70+
71+
This section guides you through setting up your development environment and testing the action locally.
72+
73+
### Prerequisites
74+
75+
- [Java](httpshttps://www.java.com/en/download/)
76+
- [Gradle](https://gradle.org/install/)
77+
78+
### Local Testing
79+
80+
1. Create a `members.yaml` file in the root of the project with the `org_name` of the organization you want to manage.
81+
82+
```yaml
83+
# members.yaml
84+
org_name: your-org-name
85+
```
86+
87+
2. Run the action in `write` mode to fetch the current members of the organization and populate the `members.yaml` file. You will need to provide a GitHub token with `admin:org` scope as an environment variable.
88+
89+
```shell
90+
INPUT_GH_TOKEN=<your-github-token> \
91+
INPUT_MODE=write \
92+
INPUT_MEMBERS_FILEPATH=$PWD/members.yaml \
93+
./gradlew run
94+
```
95+
96+
3. After the `members.yaml` file is populated, you can run the action in `sync` mode to test the synchronization logic. It's recommended to run with `INPUT_DRY_RUN=true` first to preview the changes.
97+
98+
```shell
99+
INPUT_GH_TOKEN=<your-github-token> \
100+
INPUT_MODE=sync \
101+
INPUT_DRY_RUN=true \
102+
INPUT_MEMBERS_FILEPATH=$PWD/members.yaml \
103+
./gradlew run
104+
```
105+
106+
### Unit Tests
107+
108+
To run the unit tests, use the following command:
109+
110+
```bash
111+
./gradlew test
31112
```
113+
114+
## Contributing
115+
116+
Contributions are welcome! Please follow these guidelines when contributing:
117+
118+
- **Code Quality:** Write clean, maintainable, and well-documented code.
119+
- **Conventional Commits:** Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for all commit messages.
120+
- **Pull Requests:** Create a pull request with a clear description of your changes.
121+
122+
---
123+
124+
*This README was updated by an AI assistant.*

action.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,31 @@ branding:
44
icon: 'at-sign'
55
color: 'green'
66

7-
# Inputs are provided as ENVIRONMENT VARIABLES WITH INPUT_ prefix (e.g., INPUT_MEMBERS_FILEPATH).
87
# See https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs.
98
inputs:
109
gh_token:
11-
description: GitHub Token with admin:org access
10+
description: >
11+
A GitHub token with `admin:org` scope.
12+
This is required to manage organization memberships.
13+
It is recommended to use a secret to store the token.
1214
required: true
13-
default: ""
1415
members_filepath:
15-
description: Filepath to members.yaml.
16-
required: true
16+
description: >
17+
The file path to the YAML file containing the list of members.
18+
This file will be the single source of truth for the organization's memberships.
19+
required: false
1720
default: members.yaml
1821
dry_run:
19-
description: Does not update any memberships but just fetch only
22+
description: >
23+
If set to `true`, the action will only print the changes that would be made,
24+
without actually applying them. This is useful for testing and debugging.
2025
required: false
26+
default: "false"
2127
mode:
2228
description: >
23-
There are 2 modes (sync|write).
24-
"sync" mode will try to update memberships.
25-
"write" mode will just fetch data and write YAML in `members_filepath`.
29+
The mode of operation for the action. There are two modes available: `sync` and `write`.
30+
- `sync`: This mode synchronizes the organization's memberships with the state defined in the `members_filepath` file. It will add, remove, and update members as needed to match the YAML file.
31+
- `write`: This mode fetches the current organization memberships and writes them to the `members_filepath` file. This is useful for initializing the a new `members.yaml` file.
2632
required: false
2733
default: sync
2834

0 commit comments

Comments
 (0)