Skip to content

Commit

Permalink
Merge pull request #8 from cbrgm/add-sequence
Browse files Browse the repository at this point in the history
docs(readme): add container usage, add sequence diagram
  • Loading branch information
cbrgm authored Jan 26, 2024
2 parents bfd89d9 + c1ecb9a commit d204ad9
Showing 1 changed file with 40 additions and 0 deletions.
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

0 comments on commit d204ad9

Please sign in to comment.