|
1 | 1 | name: Run PR Tests |
2 | 2 | on: [pull_request, workflow_dispatch] |
3 | 3 | concurrency: |
4 | | - group: ${{ github.workflow }}-${{ github.ref }} |
5 | | - cancel-in-progress: true |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
6 | 6 | 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 |
9 | 9 | jobs: |
10 | | - |
11 | 10 | run-sanity-tests: |
12 | 11 | needs: build-noobaa-image |
13 | 12 | uses: ./.github/workflows/sanity.yaml |
@@ -121,18 +120,31 @@ jobs: |
121 | 120 | steps.pull_base_image.outputs.pull_succeed == 'false'}} |
122 | 121 | run: | |
123 | 122 | 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 |
134 | 132 | 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 |
136 | 148 |
|
137 | 149 | - name: Build noobaa-base image |
138 | 150 | if: ${{steps.should_build_base.outputs.should_build == 'true' || |
|
0 commit comments