Skip to content

Commit

Permalink
Fix PR_COMMIT_RANGE on CI for PRs from forks (#2244)
Browse files Browse the repository at this point in the history
  • Loading branch information
gitanshu authored Mar 2, 2021
1 parent 5cf758d commit 62bbc5c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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 \
Expand Down

0 comments on commit 62bbc5c

Please sign in to comment.