From 34f8c610df3c7b1a52c625a849dbae7aecf4d1b6 Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Mon, 5 Oct 2020 17:23:08 +0200 Subject: [PATCH] Checkout all branches in GitHub Actions (#4437) By default actions/checkout@v2 only checks out the latest commit of the current branch. Unfortunately, this causes the `git diff` check in `check-pr.sh` to fail, as `master` branch isn't available`. This change checks out all commits of all branches, which allows `git diff` to work correctly. Ideally, I'd like to use the `ref` setting of actions/checkout@v2, but that only supports a single ref so it's not possible to checkout the PR branch _and_ `master` branch at the same time. --- .github/workflows/ci.yml | 2 ++ scripts/check-pr.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c0549931..858c9a8c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,8 @@ jobs: - name: Checkout uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up PR environment if: github.event.number != null diff --git a/scripts/check-pr.sh b/scripts/check-pr.sh index f5db3ab30..2b6784a40 100644 --- a/scripts/check-pr.sh +++ b/scripts/check-pr.sh @@ -49,7 +49,7 @@ function check_diff { local line local entry - git_diff=$(git diff --name-status --find-copies-harder --diff-filter=AC --relative=pages/ master) + git_diff=$(git diff --name-status --find-copies-harder --diff-filter=AC --relative=pages/ remotes/origin/master) if [ -n "$git_diff" ]; then echo -e "Check PR: git diff:\n$git_diff" >&2