@@ -22,6 +22,47 @@ gitGraph
2222 merge main
2323```
2424
25+ ---
26+
27+ ``` mermaid
28+ sequenceDiagram
29+ participant MainBranch as Main Branch
30+ participant NewBranch as New Branch
31+ participant User as User
32+ participant PullRequest as Pull Request
33+
34+ MainBranch ->> NewBranch: Checkout new branch
35+ activate NewBranch
36+ User ->> NewBranch: Make changes
37+ User ->> NewBranch: Commit changes
38+ User ->> NewBranch: Push changes to remote
39+ deactivate NewBranch
40+
41+ NewBranch ->> MainBranch: Create Pull Request (PR)
42+ activate PullRequest
43+ User ->> PullRequest: Add comment with /rebase, /autosquash, or /rebase-autosquash
44+ deactivate PullRequest
45+
46+ note over MainBranch, PullRequest: Based on comment, perform corresponding action:
47+ note over NewBranch, PullRequest: Rebase:
48+ alt
49+ PullRequest ->> NewBranch: /rebase
50+ MainBranch ->> NewBranch: Rebased
51+ end
52+ note over NewBranch, PullRequest: Autosquash:
53+ alt
54+ PullRequest ->> NewBranch: /autosquash
55+ NewBranch ->> NewBranch: Autosquash
56+ end
57+ note over NewBranch, PullRequest: Rebase and Autosquash:
58+ alt
59+ PullRequest ->> NewBranch: /rebase-autosquash
60+ NewBranch ->> NewBranch: Autosquash
61+ MainBranch ->> NewBranch: Rebased
62+ end
63+
64+ ```
65+
2566## Usage
2667
2768### Workflow Setup
@@ -59,4 +100,46 @@ jobs:
59100 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60101` ` `
61102
103+ ## Sequence Diagram: Adhoc Commands Workflow
104+
105+ ` ` ` mermaid
106+ sequenceDiagram
107+ participant User
108+ participant GitHubEvent
109+ participant GitHubActions
110+ participant CheckoutAction
111+ participant AdhocCommandsAction
112+
113+ User->>GitHubEvent : Create PR Comment with /rebase or /autosquash or /rebase-autosquash
114+ GitHubEvent-->>GitHubActions : Trigger 'created' event on issue_comment
115+
116+ alt Check if PR Comment triggers action
117+ GitHubActions-->>GitHubActions : Check if PR comment contains specific commands
118+ GitHubActions-->>CheckoutAction : Checkout the latest code
119+ CheckoutAction-->>AdhocCommandsAction : Running Adhoc commands
120+ AdhocCommandsAction-->>GitHubActions : Adhoc commands executed successfully
121+ GitHubActions-->>GitHubEvent : Complete Workflow
122+ else
123+ GitHubActions-->>GitHubEvent : Ignore event, no specific commands found
124+ end
125+
126+ ```
127+
128+ ### 1. Main Branch to New Branch: Checkout and Changes
129+
130+ - The main branch initiates the creation of a new branch.
131+ - The user makes changes in the new branch, commits them, and pushes the changes to the remote repository.
132+
133+ ### 2. New Branch to Main Branch: Create Pull Request
134+
135+ - A pull request is created from the new branch to the main branch.
136+
137+ ### 3. User to Pull Request: Trigger Commands
138+
139+ - The user adds a comment to the pull request with one of the following commands: ` /rebase ` , ` /autosquash ` , or ` /rebase-autosquash ` .
140+
141+ ### 4. Based on Comment: Rebase, Autosquash, or Both
62142
143+ - If the comment contains ` /rebase ` , the main branch rebases onto the new branch.
144+ - If the comment contains ` /autosquash ` , autosquashing is performed in the new branch.
145+ - If the comment contains ` /rebase-autosquash ` , both rebase and autosquash actions are executed.
0 commit comments