Skip to content

Commit aebc37d

Browse files
committed
Update run-pr-tests.yaml
1 parent 2eee045 commit aebc37d

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

.github/workflows/run-pr-tests.yaml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
name: Run PR Tests
22
on: [pull_request, workflow_dispatch]
33
concurrency:
4-
group: ${{ github.workflow }}-${{ github.ref }}
5-
cancel-in-progress: true
4+
group: ${{ github.workflow }}-${{ github.ref }}
5+
cancel-in-progress: true
66
permissions:
7-
actions: read # download-artifact
8-
contents: read # required for actions/checkout
7+
actions: read # download-artifact
8+
contents: read # required for actions/checkout
99
jobs:
10-
1110
run-sanity-tests:
1211
needs: build-noobaa-image
1312
uses: ./.github/workflows/sanity.yaml
@@ -121,18 +120,31 @@ jobs:
121120
steps.pull_base_image.outputs.pull_succeed == 'false'}}
122121
run: |
123122
output=true
124-
for i in $(seq 0 ${{ steps.prep.outputs.pull_tries }})
125-
do
126-
date=$(date -d "${i} days ago" +'%Y%m%d')
127-
builder_tag="quay.io/${{ steps.prep.outputs.buildertags }}${date}"
128-
echo "Trying to pull ${builder_tag}"
129-
docker pull ${builder_tag} || continue
130-
echo "Successfully pulled ${builder_tag} from quay.io"
131-
docker tag ${builder_tag} noobaa-builder
132-
output=false
133-
break
123+
should_pull=true
124+
# Check if we need to build the builder image
125+
base_files=("builder.dockerfile" ".nvmrc")
126+
for file in ${{ steps.changed_files.outputs.all_changed_files }}; do
127+
if printf '%s\n' "${base_files[@]}" | grep -x -q "$file"; then
128+
echo "File ${file} has changed, building base image."
129+
should_pull=false
130+
break;
131+
fi
134132
done
135-
echo "should_build=${output}" >> $GITHUB_OUTPUT
133+
# If not changed, try to pull
134+
if [ "$should_pull" = true ]; then
135+
for i in $(seq 0 ${{ steps.prep.outputs.pull_tries }})
136+
do
137+
date=$(date -d "${i} days ago" +'%Y%m%d')
138+
builder_tag="quay.io/${{ steps.prep.outputs.buildertags }}${date}"
139+
echo "Trying to pull ${builder_tag}"
140+
docker pull ${builder_tag} || continue
141+
echo "Successfully pulled ${builder_tag} from quay.io"
142+
docker tag ${builder_tag} noobaa-builder
143+
output=false
144+
break
145+
done
146+
fi
147+
echo "should_build=${output}" >> $GITHUB_OUTPUT
136148
137149
- name: Build noobaa-base image
138150
if: ${{steps.should_build_base.outputs.should_build == 'true' ||

0 commit comments

Comments
 (0)