Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
UmairJibran authored May 20, 2023
1 parent dc35b1f commit 7b7b68a
Showing 1 changed file with 59 additions and 19 deletions.
78 changes: 59 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,71 @@
# Gamma: Streamline Continuous Integration with Automated Branch Merging โœจ๐Ÿš€
# Gamma CI Made Easy

This repository aims to streamline the Continuous Integration (CI) flow, ensuring efficient code deployment and testing. By implementing a robust workflow, you can automate the process of merging feature branches into designated environments, such as 'staging,' 'alpha,' 'beta,' or 'pre-prod.'
This GitHub Action allows you to merge your pull requests directly into the testing branch with ease. It simplifies the process of merging pull requests by automating the necessary Git commands.

## Quick Start ๐Ÿ๐Ÿš€
## Installation

To quickly implement automated branch merging in your project, follow these steps:
Install it from [GitHub Marketplace](https://github.com/marketplace/actions/gamma-ci-made-easy)

1. Copy the `.github/workflows/mergePr.yml` file from this repository to the same directory in your project.
2. Rename the file from `mergePr.yml` to your preferred name (e.g., `merge_alpha.yml`).
3. Modify the content of the workflow file to suit your specific requirements.
## Usage

## How It Works ๐Ÿ› ๏ธโš™๏ธ
This action is triggered only when a pull request is opened, reopened, or synchronized, in other cases the action will not produce expected result. To use this action in your workflow, you can include the following snippet in your workflow file (e.g., `.github/workflows/main.yml`):

This workflow automates the process of merging code changes into the designated branch, such as 'alpha.' Here's what happens under the hood:
```YML
name: Merge PR to Testing Branch

- When a pull request (PR) is created on either the `main` or `master` branch, or new code changes are pushed to an already opened PR, the workflow will automatically merge all the code into the `alpha` branch.
- It is important to ensure that there are no conflicting changes in the code being merged.
on:
pull_request:
branches:
- master
- main
types:
- opened
- reopened
- synchronize

> **NOTE:** If you want to use a branch with a different name instead of `alpha`, you can modify the `.github/workflows/mergePr.yml` file. Just change the word `alpha` on lines [1, 16] to your preferred branch name.
jobs:
merge-pr:
runs-on: ubuntu-latest

## Benefits of Automation โœ…๐Ÿ”
steps:
- name: Merge PR to Testing Branch
uses: solenova-tech/[email protected] # replace version with latest from https://github.com/marketplace/actions/gamma-ci-made-easy
with:
target-branch: 'staging' # replace this name with your testing branch
token: ${{ secrets.GITHUB_TOKEN }} # Read below on how to get this

By automating the merging of feature branches, you can achieve several benefits:
```

- **Efficiency:** Eliminate the manual effort required to merge each feature branch, saving valuable time for developers and streamlining the CI process. โฐ๐Ÿ’ช
- **Consistency:** Ensure that the designated environment (e.g., 'alpha') consistently reflects the latest code changes, minimizing discrepancies between branches. ๐Ÿ”„โœจ
- **Reliability:** Reduce the risk of human error during manual merges, enhancing the overall reliability of the CI workflow. ๐ŸšซโŒ๐Ÿ™…โ€โ™‚๏ธ
- **Scalability:** As your project grows and more feature branches are created, automation allows for seamless integration and testing in the designated environment. ๐Ÿ“ˆ๐Ÿš€
This action requires a personal access token (PAT) with appropriate permissions to perform the merge operation. Make sure you provide the token input with a valid GitHub Personal Access Token. Create a PAT with the REPO permission using the following steps:
- Sign in to your GitHub account.
- Click on your profile icon in the top-right corner, and then click on "Settings" in the dropdown menu.
- In the left sidebar, click on "Developer settings".
- In the left sidebar, click on "Personal access tokens" to expand the collapsable sub-menu.
- Click on the tokens (classic)
- Click on the "Generate new token" button.
- In the sub-menu select "Generate new token (classic)"
- Provide a descriptive note for your token in the "Note" field. This will help you identify the token's purpose later.
- Select the desired scopes or permissions for the token. Scopes define the level of access the token will have. (for our use only "**repo**" permission is enough.
- If you want the token to have access only during a specific time period, you can set an expiration date for it.
- Once you have configured the note and scopes, click on the "Generate token" button.
- GitHub will generate a new Personal Access Token for you. Copy the token value.
- After generating the token, it will be displayed only once. GitHub will not show it to you again. If you lose the token, you will need to generate a new one.
- Navigate to the main page of your repository on GitHub.
- Click on the "Settings" tab located near the top-right corner of the repository page.
- In the left sidebar, click on "Secrets and varialbes".
- In the now new expanded sub menu, click on "Actions"
- Click on the "New repository secret" button.
- Enter a name for your secret in the "Name" field. This should be a descriptive name that helps identify the purpose of the secret. In the above example, we are using the 'GITHUB_TOKEN' as Name
- In the "Value" field, enter the actual value of the secret. This can be a password, an access token, or any other sensitive information that you want to securely store, in our case the PAT that you copied above.
- Click on the "Add secret" button to save the secret.
**Note that, PAT grants significant access to your GitHub account, so treat them like passwords and keep them secure.**

By adopting this automated branch merging approach, you can enhance your CI process and facilitate the seamless integration of new features. Don't let manual merges slow you downโ€”automate your workflow today! ๐Ÿ’ช๐Ÿš€
## Inputs

`target-branch` (optional): The branch in which you want to merge the pull request. Defaults to 'alpha'.

`token` (required): GitHub Personal Access Token. Make sure to provide a valid token.

## License

This project is licensed under the MIT License

0 comments on commit 7b7b68a

Please sign in to comment.