Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(readme): add container usage, add sequence diagram #8

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ Branches that meet all these criteria are considered as stale or abandoned and e
- `dry-run`: Optional - Perform a dry run without actually deleting branches. Defaults to `true`, meaning no branches will be deleted.
- `rate-limit`: Optional - Stop the action if it exceeds 95% of the GitHub API rate limit. Defaults to `true`, ensuring the action is halted before hitting the rate limit e.g. exiting with status code `0` instead of failing.

### Container Usage

This action can be executed independently from workflows within a container. To do so, use the following command:

```
podman run --rm -it ghcr.io/cbrgm/cleanup-stale-branches-action:v1 --help
```

### Workflow Usage

```yaml
Expand Down Expand Up @@ -91,6 +99,38 @@ In this advanced example:
* The action is not in `dry-run` mode, meaning branches will actually be deleted.
* The `rate-limit` check is enabled to prevent exceeding the GitHub API rate limit.

### High-level Functionality

```mermaid
sequenceDiagram
participant GitHubAction
participant GitHubAPI

Note over GitHubAction,GitHubAPI: GitHub Action: cleanup-stale-branches-action

GitHubAction->>GitHubAPI: Initialize (Token, Repo Info)
activate GitHubAPI
GitHubAPI-->>GitHubAction: Repository Validated

loop For each Branch in Repository
GitHubAction->>GitHubAPI: Fetch Branch Details
GitHubAPI-->>GitHubAction: Return Branch Details
GitHubAction->>GitHubAction: Evaluate Branch Deletion Criteria
alt Branch Meets Criteria
alt Dry Run Enabled
GitHubAction->>GitHubAction: Log Deletable Branch (No Action)
else Dry Run Disabled
GitHubAction->>GitHubAPI: Delete Branch
GitHubAPI-->>GitHubAction: Branch Deleted
end
else Branch Does Not Meet Criteria
GitHubAction->>GitHubAction: Log Skipping Branch
end
end

deactivate GitHubAPI
```

### Local Development

You can build this action from source using `Go`:
Expand Down
Loading