|
| 1 | +# Checkout Merge |
| 2 | + |
| 3 | +This action synthesizes the merge commit GitHub would give you via `refs/pull/X/merge`. |
| 4 | + |
| 5 | +With GitHub.com's current implementation as of Dec 8, 2021, if it was able to make a |
| 6 | +merge commit, and then a push causes the current state to be not mergable, the |
| 7 | +`refs/pull/X/merge` ref may stick around resulting in confusing output. |
| 8 | + |
| 9 | +With this action, instead, you will not get a merge commit. |
| 10 | + |
| 11 | +If you use [@actions/checkout](https://github.com/actions/checkout) to try to |
| 12 | +check out `refs/pull/X/merge` and it doesn't exist, the action will make three |
| 13 | +attempts (failing each time), and then leave your workflow in a failed state |
| 14 | +and your user with a fairly confusing log. |
| 15 | + |
| 16 | +If you instead use [@actions/checkout](https://github.com/actions/checkout) to |
| 17 | +check out the base commit, then you can use this action to get a merge commit. |
| 18 | +If it isn't able to, it can produce an error message that is hopefully easier |
| 19 | +for users to understand, and allow you to decide whether your workflow should |
| 20 | +✅ or ❌. |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +```yaml |
| 25 | + - name: checkout |
| 26 | + uses: actions/checkout@v2 |
| 27 | + - name: checkout-merge |
| 28 | + if: "contains(github.event_name, 'pull_request')" |
| 29 | + uses: check-spelling/checkout-merge@main |
| 30 | + with: |
| 31 | + # Base for merge (it will be checked out) |
| 32 | + # Default: ${{ github.event.pull_request.base.sha }} |
| 33 | + base_ref: '' |
| 34 | + |
| 35 | + # Head for merge (it will be fetched and merged) |
| 36 | + # Default: ${{ github.event.pull_request.head.sha }} |
| 37 | + head_ref: '' |
| 38 | + |
| 39 | + # Relative path under $GITHUB_WORKSPACE to the repository |
| 40 | + # Default: . |
| 41 | + path: '' |
| 42 | + |
| 43 | + # Suppress reporting errors (consumers would report the message themselves) |
| 44 | + # By default, this action reports errors in the workflow overview. |
| 45 | + # If you want to handle reporting the error in some other manner, |
| 46 | + # you can set this flag. |
| 47 | + # Default: false |
| 48 | + do_not_report: '' |
| 49 | + - if: env.MERGE_FAILED != '1' |
| 50 | + run: ... |
| 51 | +``` |
| 52 | +
|
| 53 | +### Outputs |
| 54 | +
|
| 55 | +* `message` - Message describing what prevented the action from producing a merge commit. |
| 56 | + |
| 57 | +* `status` - `success` or `failed` |
| 58 | + |
| 59 | +### Environment products |
| 60 | + |
| 61 | +* `$MERGE_FAILED` will be set to `1` if a merge can't be created. |
0 commit comments