Skip to content

Commit 11d9aa9

Browse files
authored
Include common example for fetching PR base-ref
Since this seems to be a common scenario and is generating a lot of discussion (actions#93), it seems worthwhile to add it to the readme as an example. I placed it before the other fetch examples because this use-case still only fetches minimal history (only adding one additional ref); so it seems helpful to place this above the other fetch examples which all do deeper fetches.
1 parent 94c2de7 commit 11d9aa9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous
112112
113113
- [Checkout a different branch](#Checkout-a-different-branch)
114114
- [Checkout HEAD^](#Checkout-HEAD)
115+
115116
- [Checkout multiple repos (side by side)](#Checkout-multiple-repos-side-by-side)
116117
- [Checkout multiple repos (nested)](#Checkout-multiple-repos-nested)
117118
- [Checkout multiple repos (private)](#Checkout-multiple-repos-private)
118119
- [Checkout pull request HEAD commit instead of merge commit](#Checkout-pull-request-HEAD-commit-instead-of-merge-commit)
119120
- [Checkout pull request on closed event](#Checkout-pull-request-on-closed-event)
121+
- [Fetch pull request base-ref in addition to merge commit (for diffing)](#Fetch-pull-request-base-ref-in-addition-to-merge-commit-for-diffing)
120122
- [Fetch all tags](#Fetch-all-tags)
121123
- [Fetch all branches](#Fetch-all-branches)
122124
- [Fetch all history for all tags and branches](#Fetch-all-history-for-all-tags-and-branches)
123125
126+
124127
## Checkout a different branch
125128
126129
```yaml
@@ -207,6 +210,15 @@ jobs:
207210
- uses: actions/checkout@v2
208211
```
209212

213+
## Fetch pull request base-ref in addition to merge commit (for diffing)
214+
215+
```yml
216+
- uses: actions/checkout@v2
217+
- name: Fetch base_ref HEAD
218+
run: git fetch --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}}
219+
- run: git diff origin/${{github.base_ref}}..HEAD
220+
```
221+
210222
## Fetch all tags
211223

212224
```yaml

0 commit comments

Comments
 (0)