From 62bbc5cec70480e3bf2039cea7f130befecbef10 Mon Sep 17 00:00:00 2001 From: Gitanshu Sardana Date: Tue, 2 Mar 2021 11:40:54 -0800 Subject: [PATCH] Fix PR_COMMIT_RANGE on CI for PRs from forks (#2244) --- .github/workflows/ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5764155fa..befb255e40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,7 @@ jobs: --target garage-dev \ -t "${DOCKER_TAG}" \ --build-arg GARAGE_GH_TOKEN \ - --cache-from="docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + --cache-from="rlworkgroup/garage" - name: Push to cache (GitHub Package Registry) run: | docker tag "${DOCKER_TAG}" "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" @@ -100,16 +100,20 @@ jobs: steps: - name: Login to GitHub Package Registry - if: github.event_name == 'pull_request' || github.event_name == 'repository_dispatch' + if: github.event_name == 'pull_request' || env.IS_PR_FROM_FORK run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin - name: Pull from cache (GitHub Package Registry) - if: github.event_name == 'pull_request' || github.event_name == 'repository_dispatch' + if: github.event_name == 'pull_request' || env.IS_PR_FROM_FORK run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" - name: Tag docker image - if: github.event_name == 'pull_request' || github.event_name == 'repository_dispatch' + if: github.event_name == 'pull_request' || env.IS_PR_FROM_FORK run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Export commit range for fork PRs + if: env.IS_PR_FROM_FORK + run: | + echo "PR_COMMIT_RANGE=${{ github.event.client_payload.pull_request.base.sha }}...${{ github.event.client_payload.pull_request.head.sha }}" >> $GITHUB_ENV - name: Check pre-commit - if: github.event_name == 'pull_request' || github.event_name == 'repository_dispatch' + if: github.event_name == 'pull_request' || env.IS_PR_FROM_FORK run: | docker run \ -e PR_COMMIT_RANGE \