-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.{md,yml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: "Test Action" | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
env: | ||
source: "${{ format('{0}-{1}-{2}', 'tests-source', github.run_id, github.run_number) }}" | ||
destination: "${{ format('{0}-{1}-{2}', 'tests-destination', github.run_id, github.run_number) }}" | ||
example-file: "example-change.test" | ||
|
||
jobs: | ||
fixtures: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: fregante/setup-git-user@v1 | ||
- run: "git checkout -b ${{ env.destination }}" | ||
- run: "git checkout -b ${{ env.source }}" | ||
- run: "echo ${{ env.destination }} > ${{ env.example-file }}" | ||
- run: "git add example-change.test" | ||
- run: "git commit -m 'chore: Add example file'" | ||
- run: "git push --set-upstream origin ${{ env.destination }} ${{ env.source }}" | ||
merge: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- fixtures | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: "${{ env.destination }}" | ||
fetch-depth: 0 | ||
- name: "Merge example branch ${{ env.source }} into ${{ env.destination }}" | ||
uses: ./ | ||
with: | ||
from: "origin/${{ env.source }}" | ||
merge-without-changes: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Create a branch equal to the current branch | ||
run: git branch equal-branch | ||
- name: Merge equal branch | ||
uses: ./ | ||
with: | ||
from: "equal-branch" | ||
assert: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- merge | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: "${{ env.destination }}" | ||
- id: example-file | ||
run: "echo ::set-output name=body::$(cat ${{ env.example-file }})" | ||
- name: Test merge succeeded by verifying source file exists in destination branch | ||
uses: pr-mpt/actions-assert@v2 | ||
with: | ||
assertion: npm://@assertions/is-equal | ||
expected: "${{ env.destination }}" | ||
actual: "${{ steps.example-file.outputs.body }}" | ||
clean-up: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- assert | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Delete test branches | ||
run: git push origin --delete ${{ env.source }} ${{ env.destination }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 > LIMITED and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Merge Into Current Branch | ||
|
||
A GitHub Action for keeping two branches in sync by merging in any `source` | ||
branch changes using `git` locally -- not the GitHub API. | ||
|
||
``` | ||
pr-mpt/actions-merge-branch@v1 | ||
``` | ||
|
||
## Inputs | ||
|
||
| ID | Description | Default | Examples | | ||
| ---- | ----------- | ------- | -------- | | ||
| **`from`** | **Branch to merge into the current branch** | **<kbd>required</kbd>** | **`main`** | | ||
| `author` | Merge commit author | GitHub Actions<sup>[1]</sup> | `Alice <[email protected]>` | | ||
| `strategy` | Merge strategy with options | `recursive -Xtheirs` | `recursive`<br/>`recursive -Xours` | | ||
| `push` | Push merge commit to origin? | `true` | `true` `false` | | ||
|
||
[1] [`github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>`][users/github-actions] | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
|
||
## Examples | ||
|
||
### Synchronise `release` branch with `main` | ||
|
||
Every push to `main` is synchronised to the `release` branch by merging in any | ||
changes. | ||
|
||
```yaml | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
synchronise-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: "release" | ||
fetch-depth: 0 | ||
- uses: pr-mpt/actions-merge-branch@v0 | ||
with: | ||
from: "origin/main" | ||
``` | ||
[users/github-actions]: https://api.github.com/users/github-actions%5Bbot%5D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: "Merge Into Current Branch" | ||
description: "Synchronise branches using Git merge with a (recursive) strategy" | ||
branding: | ||
icon: "git-merge" | ||
color: "blue" | ||
inputs: | ||
from: | ||
description: "Branch to merge into the current branch" | ||
required: true | ||
author: | ||
description: "Commit author in Git author format" | ||
default: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" | ||
required: true | ||
strategy: | ||
description: "Merge strategy with any strategy options" | ||
default: "recursive -Xtheirs" | ||
required: true | ||
push: | ||
description: "Push commit to origin?" | ||
default: "true" | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set commit author information | ||
shell: bash | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
- name: Merge ${{ inputs.from }} with ${{ inputs.strategy }} strategy | ||
shell: bash | ||
run: git merge ${{ inputs.from }} -s ${{ inputs.strategy }} --no-ff --no-commit | ||
- name: "Commit changes from ${{ inputs.from }}" | ||
shell: bash | ||
run: | | ||
git diff-index --quiet HEAD \ | ||
|| git commit -am 'Merge branch ${{ inputs.from }}' --author='${{ inputs.author }}' | ||
- name: "Push changes from ${{ inputs.from }} to origin" | ||
shell: bash | ||
run: | | ||
if [ "${{ inputs.push }}" == "true" ] | ||
then | ||
git push origin HEAD | ||
fi |