A GitHub action that creates a workflow with four eyes principle
- PR Author creates a pull request
- The pull request is automatically assigned to 2 code reviewers from the
githubUserNames
list provided - The first code reviewer, reviews the code and provide feedback
- After the feedback provided by the first code reviewer, a slack notification is sent to the second code reviewer
- Second code reviewer ensures all the review comments from the first code reviewer have been addressed properly
- If required, adds review comments as well
- After the second code reviewer's approval, a Slack notification is sent to the PR Author
- If there is no change requested then the PR is ready to be merged 🚀
- It keeps your Slack channel as clean as possible as notifications related to a specific PR starts a thread and all the related activities of the pull request are sent as a thread reply Check it here
Required The GitHub Token that has access to the workflow scope .
Required The Slack Bot User OAuth Token starts with xoxb-
which will be required to send messages to a Slack channel.
Required The Slack channel for notifications to be sent.
- name: Checkout
uses: actions/checkout@v3
- name: Run pull request workflow
uses: cakarci/pull-request-workflow@v1
with:
github-token: ${{ secrets.GH_TOKEN }}
slack-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel-id: '{Your public slack channel id}'
-
-
name: 'pull-request-workflow' on: pull_request: types: [ assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, converted_to_draft, ready_for_review, locked, unlocked, review_requested, review_request_removed, auto_merge_enabled, auto_merge_disabled ] pull_request_review: types: [submitted, edited, dismissed] pull_request_review_comment: types: [created, edited, deleted] issue_comment: types: [created, edited, deleted] schedule: - cron: '0 10 * * 1-5' jobs: pull_request_workflow: runs-on: ubuntu-latest name: A job that notifies slack on PR events steps: - name: Checkout uses: actions/checkout@v3 - name: Run pull request workflow uses: cakarci/pull-request-workflow@v1 with: github-token: ${{ secrets.GH_TOKEN }} slack-token: ${{ secrets.SLACK_BOT_TOKEN }} slack-channel-id: '{Your public slack channel id}'
-
-
-
{ "teamName": "Consumer Experience", "githubUserNames": ["pcakarci", "scakarci", "cakarci"], "githubSlackUserMapper": { "pcakarci": "U04L1AQ8H8U", "scakarci": "U04LNHEVA48", "cakarci": "U035MNNF8LW" }, "remindAfter": 12 }
-
teamName
Optional- Currently, not used
-
githubUserNames
Required- All the users defined in the
githubUserNames
list should have read/write access to the repository
- All the users defined in the
-
githubSlackUserMapper
Required- object should include
githubUserName
as akey
andSlack Member ID
as avalue
How to get Slack Member ID
- object should include
-
remindAfter
Optional- If set then pull request collaborators (PR Author, Reviewers) will be reminded after
x
hours if the PR is waiting on them. - In order to remind collaborators, the following schedule event needs to be defined in your
pull-request-workflow.yml
-
on: schedule: - cron: '0 10 * * 1-5'
cron: '0 10 * * 1-5'
means “At 10:00 on every day-of-week from Monday through Friday.”
- If set then pull request collaborators (PR Author, Reviewers) will be reminded after
-
-
Add your SECRETS to your repo (Check how to create a repository secret)
- SLACK_BOT_TOKEN
- Copy the
Bot User OAuth Token
and add it to your repository secret asSLACK_BOT_TOKEN
- Copy the
- GH_TOKEN
- Create a Personal Access Token
- Add the GitHub personal access token scopes like in this image
- Add it to your repository secret as
GH_TOKEN
- SLACK_BOT_TOKEN
-
To test the workflow run, create a PR in your repository and check if the notifications are sent to your public Slack channel 💥
Developed with ❤️ by Salih Cakarci