From 7d947b30c300ecbe5e0f00f584659e6fef490530 Mon Sep 17 00:00:00 2001 From: George Stagg Date: Mon, 17 Jun 2024 09:26:32 +0100 Subject: [PATCH] Fix testing PR from repository fork (#444) --- .github/workflows/deploy.yml | 9 +-------- .github/workflows/test.yml | 22 +++++++++++++++------- Dockerfile | 3 ++- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7c20beb6..6e2443dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -168,20 +168,13 @@ jobs: uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} - - name: Short commit SHA - id: short - run: | - SHA="${{github.event.pull_request.head.sha}}${{ github.sha }}" - SHORT_SHA=${SHA:0:7} - echo "sha: $SHORT_SHA" - echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT - name: Build and publish Docker image uses: docker/build-push-action@v5 with: context: . push: true build-args: | - WEBRCI_SHA=${{ steps.short.outputs.sha }} + WEBRCI_SHA=${{ github.sha }} MAKE_LIBS_TARGET=all tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70006338..65e19f21 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,20 +47,28 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Short commit SHA - id: short + - name: Obtain git ref + id: ref run: | - SHA="${{github.event.pull_request.head.sha}}${{ github.sha }}" - SHORT_SHA=${SHA:0:7} - echo "sha: $SHORT_SHA" - echo "sha=$SHORT_SHA" >> $GITHUB_OUTPUT + if [ ${{ github.event.pull_request.head.sha }} ]; then + REPO="https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git" + SHA="${{ github.event.pull_request.head.sha }}" + else + REPO="https://github.com/${{ github.repository }}.git" + SHA="${{ github.sha }}" + fi + echo "repo: $REPO" + echo "repo=$REPO" >> $GITHUB_OUTPUT + echo "sha: $SHA" + echo "sha=$SHA" >> $GITHUB_OUTPUT - name: Build Docker image uses: docker/build-push-action@v5 with: context: . push: false build-args: | - WEBRCI_SHA=${{ steps.short.outputs.sha }} + WEBRCI_REPO=${{ steps.ref.outputs.repo }} + WEBRCI_SHA=${{ steps.ref.outputs.sha }} MAKE_LIBS_TARGET=default build-nix: runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 120f158f..90b8932e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,7 +72,8 @@ RUN rig add 4.4.0 --without-pak RUN /opt/R/current/bin/R -q -e 'install.packages("pak", lib = .Library)' # Download webR and configure for LLVM flang -RUN git clone https://github.com/r-wasm/webr.git /opt/webr +ARG WEBRCI_REPO="https://github.com/r-wasm/webr.git" +RUN git clone ${WEBRCI_REPO} /opt/webr WORKDIR /opt/webr ARG WEBRCI_SHA=HEAD RUN git checkout ${WEBRCI_SHA}