|
1 | | -# pr-spark |
| 1 | +# 🚀 PR Spark |
| 2 | + |
| 3 | +**PR Spark** is a GitHub Action that **automatically creates Pull Requests** between branches using the GitHub API. |
| 4 | +It helps you **streamline workflows**, keep branches in sync, and speed up your CI/CD pipelines. |
| 5 | + |
| 6 | +✨ Perfect for: |
| 7 | +- Automating routine Pull Requests |
| 8 | +- Keeping feature branches up to date |
| 9 | +- Enforcing consistent workflows |
| 10 | +- Saving time in collaborative projects |
| 11 | + |
| 12 | + |
| 13 | +----- |
| 14 | + |
| 15 | +### How to Use |
| 16 | + |
| 17 | +To use this Action in your workflow, add the following step to your `.yml` file: |
| 18 | + |
| 19 | +```yaml |
| 20 | +- name: Create Pull Request |
| 21 | + uses: ws2git/pr-spark@v1 |
| 22 | + with: |
| 23 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + title: 'Title of your Pull Request' |
| 25 | + body: 'Detailed description of the PR.' |
| 26 | + source-branch: 'my-source-branch' |
| 27 | + dest-branch: 'main' |
| 28 | +``` |
| 29 | +
|
| 30 | +
|
| 31 | +### Inputs |
| 32 | +
|
| 33 | +The following inputs can be used to configure the Action. |
| 34 | +
|
| 35 | +| Input Name | Required | Description | Example | |
| 36 | +| :--- | :---: | :--- | :--- | |
| 37 | +| `github-token` | **Yes** | The GitHub token used for API authentication. The default `secrets.GITHUB_TOKEN` already has the necessary permissions to create a Pull Request. | `${{ secrets.GITHUB_TOKEN }}` | |
| 38 | +| `title` | **Yes** | The title of the Pull Request. Can be a static string or a dynamic variable. | `"Project Deploy"` | |
| 39 | +| `body` | No | The description (body) of the Pull Request. Supports Markdown for formatting. | `"This PR contains the new features..."` | |
| 40 | +| `source-branch` | **Yes** | The name of the source branch (the branch where changes were made). | `"feature/new-feature"` | |
| 41 | +| `dest-branch` | **Yes** | The name of the destination branch (the branch where the PR will be opened). | `"main"` | |
| 42 | + |
| 43 | + |
| 44 | +### Outputs |
| 45 | + |
| 46 | +The Action generates one output that can be used in subsequent steps of your workflow. |
| 47 | + |
| 48 | +| Output Name | Description | |
| 49 | +| :--- | :--- | |
| 50 | +| `pull-request-url` | The full URL of the created Pull Request. | |
| 51 | + |
| 52 | + |
| 53 | +**Output Usage Example:** |
| 54 | + |
| 55 | +```yaml |
| 56 | +- name: Log PR URL |
| 57 | + run: echo "Created PR URL: ${{ steps.your-action-step-id.outputs.pull-request-url }}" |
| 58 | +``` |
| 59 | + |
| 60 | +Make sure to replace `your-action-step-id` with the `id` of the step where you call the Action. |
| 61 | + |
| 62 | + |
| 63 | +### Full Workflow Example |
| 64 | + |
| 65 | +This is an example of a complete workflow that uses the Action to open a PR. It demonstrates how to use the Action dynamically by creating a title with the current date. |
| 66 | + |
| 67 | +```yaml |
| 68 | +name: Example Workflow |
| 69 | +
|
| 70 | +on: |
| 71 | + push: |
| 72 | + branches: |
| 73 | + - develop |
| 74 | +
|
| 75 | +jobs: |
| 76 | + create-pr: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - name: Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | +
|
| 82 | + - name: Generate date for the title |
| 83 | + id: set-date |
| 84 | + run: | |
| 85 | + # Gets the current date in 'dd-mm-yyyy' format |
| 86 | + CURRENT_DATE=$(date +"%d-%m-%Y") |
| 87 | + echo "date=$CURRENT_DATE" >> "$GITHUB_OUTPUT" |
| 88 | +
|
| 89 | + - name: Create Pull Request |
| 90 | + id: create-pr |
| 91 | + uses: ws2git/pr-spark@v1 |
| 92 | + with: |
| 93 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + # The title is now dynamic, using the output variable from the previous step |
| 95 | + title: "Deploy ${{ steps.set-date.outputs.date }}" |
| 96 | + body: "This is a test PR generated by the custom action." |
| 97 | + source-branch: "develop" |
| 98 | + dest-branch: "main" |
| 99 | +
|
| 100 | + - name: Display Created PR URL |
| 101 | + run: echo "Created PR URL: ${{ steps.create-pr.outputs.pull-request-url }}" |
| 102 | +``` |
| 103 | + |
| 104 | +----- |
| 105 | + |
| 106 | +### Support |
| 107 | + |
| 108 | +If you find any issues or have suggestions for improvements, feel free to open an [Issue](https://github.com/ws2git/pr-spark/issues) in this repository. |
0 commit comments