Skip to content

Commit 39e626a

Browse files
committed
by run ID
1 parent 78229d9 commit 39e626a

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,6 @@ jobs:
195195
196196
- name: Download and test
197197
run: |
198-
mvn clean test -Dh3.github.artifacts.use=true -Dh3.github.artifacts.ref=${{ github.sha }}
198+
mvn clean test -Dh3.github.artifacts.use=true -Dh3.github.artifacts.by_run=${{ github.run_id }}
199199
env:
200200
GH_TOKEN: ${{ github.token }}

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<h3.system.prune>false</h3.system.prune>
7474
<h3.dockcross.tag>20210624-de7b1b0</h3.dockcross.tag>
7575
<h3.github.artifacts.use>false</h3.github.artifacts.use>
76-
<h3.github.artifacts.ref />
76+
<h3.github.artifacts.by_run />
7777
<!-- Used for passing additional arguments to surefire when using JaCoCo -->
7878
<h3.additional.argLine />
7979

@@ -271,7 +271,7 @@
271271
<argument>${h3.system.prune}</argument>
272272
<argument>${h3.dockcross.tag}</argument>
273273
<argument>${h3.github.artifacts.use}</argument>
274-
<argument>${h3.github.artifacts.ref}</argument>
274+
<argument>${h3.github.artifacts.by_run}</argument>
275275
</arguments>
276276
</configuration>
277277
</execution>

src/main/c/h3-java/build-h3.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# github-artifacts - When set, all build artifacts are retrieved from Github
2929
# Actions artifacts rather than built locally (overrides
3030
# all other settings.)
31-
# github-artifacts-ref - When set, override the default revision to pull artifacts from
31+
# github-artifacts-run - When set, override the default revision to pull artifacts from
3232
# for `github-artifacts`.
3333
#
3434
# This script downloads H3, builds H3 and the H3-Java native library, and
@@ -45,10 +45,10 @@ USE_DOCKER=$3
4545
SYSTEM_PRUNE=$4
4646
DOCKCROSS_TAG=$5
4747
GITHUB_ARTIFACTS=$6
48-
GITHUB_ARTIFACTS_REF=$7
48+
GITHUB_ARTIFACTS_RUN=$7
4949

5050
if $GITHUB_ARTIFACTS; then
51-
src/main/c/h3-java/pull-from-github.sh "$GITHUB_ARTIFACTS_REF"
51+
src/main/c/h3-java/pull-from-github.sh "$GITHUB_ARTIFACTS_RUN"
5252
# The build of the library below is still needed for the binding-functions file
5353
fi
5454

src/main/c/h3-java/pull-from-github.sh

+14-11
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,27 @@
2424

2525
set -eox pipefail
2626

27-
GITHUB_ARTIFACTS_REF=$1
27+
GITHUB_ARTIFACTS_RUN=$1
2828

29-
if [ -z "$GITHUB_ARTIFACTS_REF" ]; then
30-
GIT_REVISION=$(git rev-parse HEAD)
31-
else
32-
GIT_REVISION="$GITHUB_ARTIFACTS_REF"
33-
fi
3429
EXTRACT_TO=src/main/resources
3530

36-
echo downloading artifacts for $GIT_REVISION
37-
3831
mkdir -p target
3932
pushd target
4033

41-
TO_DOWNLOAD=$(gh api \
34+
ARTIFACTS_LIST=$(gh api \
4235
-H "Accept: application/vnd.github+json" \
43-
/repos/{owner}/{repo}/actions/artifacts \
44-
| jq ".artifacts[] | select(.workflow_run.head_sha == \"$GIT_REVISION\")")
36+
/repos/{owner}/{repo}/actions/artifacts)
37+
38+
if [ -z "$GITHUB_ARTIFACTS_RUN" ]; then
39+
GIT_REVISION=$(git rev-parse HEAD)
40+
echo "downloading artifacts for sha $GIT_REVISION"
41+
TO_DOWNLOAD=$(echo "$ARTIFACTS_LIST" \
42+
| jq ".artifacts[] | select(.workflow_run.head_sha == \"$GIT_REVISION\")")
43+
else
44+
echo "downloading artifacts for run $GITHUB_ARTIFACTS_RUN"
45+
TO_DOWNLOAD=$(echo "$ARTIFACTS_LIST" \
46+
| jq ".artifacts[] | select(.workflow_run.id == \"$GITHUB_ARTIFACTS_RUN\")")
47+
fi
4548

4649
echo $TO_DOWNLOAD | jq -c '.' | while read artifactline; do
4750
ARTIFACT_NAME=$(echo $artifactline | jq -r .name)

0 commit comments

Comments
 (0)