| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Automate custom commands on pull requests using GitHub Actions.
This GitHub Action allows you to execute ad-hoc commands on pull requests dynamically in response to comments. It provides a flexible way to trigger specific tasks based on user interactions.
gitGraph
commit "1"
commit "2"
branch develop
commit "3"
commit "4"
commit "5"
checkout main
commit "6"
commit "7"
checkout develop
commit "(rebase and squash here)"
merge main
sequenceDiagram
participant MainBranch as Main Branch
participant NewBranch as New Branch
participant User as User
participant PullRequest as Pull Request
MainBranch ->> NewBranch: Checkout new branch
activate NewBranch
User ->> NewBranch: Make changes
User ->> NewBranch: Commit changes
User ->> NewBranch: Push changes to remote
deactivate NewBranch
NewBranch ->> MainBranch: Create Pull Request (PR)
activate PullRequest
User ->> PullRequest: Add comment with /rebase, /autosquash, or /rebase-autosquash
deactivate PullRequest
note over MainBranch, PullRequest: Based on comment, perform corresponding action:
note over NewBranch, PullRequest: Rebase:
alt
PullRequest ->> NewBranch: /rebase
MainBranch ->> NewBranch: Rebased
end
note over NewBranch, PullRequest: Autosquash:
alt
PullRequest ->> NewBranch: /autosquash
NewBranch ->> NewBranch: Autosquash
end
note over NewBranch, PullRequest: Rebase and Autosquash:
alt
PullRequest ->> NewBranch: /rebase-autosquash
NewBranch ->> NewBranch: Autosquash
MainBranch ->> NewBranch: Rebased
end
Create a GitHub Actions workflow YAML file, for example, .github/workflows/adhoc_commands.yml:
name: PR Adhoc commands
on:
issue_comment:
types: [created]
jobs:
build:
name: PR-Adhoc-Commands
runs-on: ubuntu-latest
if: >-
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/rebase') ||
contains(github.event.comment.body, '/autosquash') ||
contains(github.event.comment.body, '/rebase-autosquash')
)
steps:
- name: Checkout the latest code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Running Adhoc commands
uses: GirishCodeAlchemy/githubaction-runtime-adhoc-pr-commands@v1
with:
autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} sequenceDiagram
participant User
participant GitHubEvent
participant GitHubActions
participant CheckoutAction
participant AdhocCommandsAction
User->>GitHubEvent: Create PR Comment with /rebase or /autosquash or /rebase-autosquash
GitHubEvent-->>GitHubActions: Trigger 'created' event on issue_comment
alt Check if PR Comment triggers action
GitHubActions-->>GitHubActions: Check if PR comment contains specific commands
GitHubActions-->>CheckoutAction: Checkout the latest code
CheckoutAction-->>AdhocCommandsAction: Running Adhoc commands
AdhocCommandsAction-->>GitHubActions: Adhoc commands executed successfully
GitHubActions-->>GitHubEvent: Complete Workflow
else
GitHubActions-->>GitHubEvent: Ignore event, no specific commands found
end
| Back | FazBrowse Home | New Git URL |