@@ -42,28 +42,112 @@ jobs:
4242 uses : ./.github/workflows/warp-nc-tests.yaml
4343
4444 build-noobaa-image :
45+ name : Build Noobaa Image
4546 runs-on : ubuntu-latest
4647 timeout-minutes : 90
4748 steps :
4849 - name : Checkout
4950 uses : actions/checkout@v4
5051
51- - name : make noobaa image
52- run : make tester
52+ - name : Prepare Tags
53+ id : prep
54+ run : |
55+ DOCKER_BUILDER_IMAGE=noobaa/noobaa-builder
56+ DOCKER_BASE_IMAGE=noobaa/noobaa-base
57+ if [[ -n ${{github.base_ref}} ]]; then
58+ #on pull request, use target branch
59+ BRANCH=${{github.base_ref}}
60+ else
61+ #on push, use the pushed branch
62+ BRANCH=${{github.ref_name}}
63+ fi
64+ BUILDER_TAGS="${DOCKER_BUILDER_IMAGE}:${BRANCH}-"
65+ BASE_TAGS="${DOCKER_BASE_IMAGE}:${BRANCH}-"
66+ EARLIEST_VERSION_PAST=20
67+ echo "basetags=${BASE_TAGS}" >> $GITHUB_OUTPUT
68+ echo "buildertags=${BUILDER_TAGS}" >> $GITHUB_OUTPUT
69+ echo "pull_tries=${EARLIEST_VERSION_PAST}" >> $GITHUB_OUTPUT
70+
71+ - name : Check changed files
72+ id : changed_files
73+ uses : tj-actions/changed-files@v44
74+
75+ - name : Should build noobaa base image
76+ id : should_build_base
77+ run : |
78+ base_files=("package.json" "base.dockerfile" ".nvmrc")
79+ output=false
80+ for file in ${{ steps.changed_files.outputs.all_changed_files }}; do
81+ if printf '%s\n' "${base_files[@]}" | grep -x -q "$file"; then
82+ echo "File ${file} has changed, building base image."
83+ output=true
84+ break;
85+ fi
86+ done
87+ echo "should_build=${output}" >> $GITHUB_OUTPUT
88+
89+ - name : Pull noobaa-base image
90+ id : pull_base_image
91+ if : ${{ steps.should_build_base.outputs.should_build == 'false' }}
92+ run : |
93+ output=false
94+ for i in $(seq 0 ${{ steps.prep.outputs.pull_tries }})
95+ do
96+ date=$(date -d "${i} days ago" +'%Y%m%d')
97+ base_tag="quay.io/${{ steps.prep.outputs.basetags }}${date}"
98+ echo "Trying to pull ${base_tag}"
99+ docker pull ${base_tag} || continue
100+ echo "Successfully pulled ${base_tag} from quay.io"
101+ docker tag ${base_tag} noobaa-base
102+ output=true
103+ break
104+ done
105+ echo "pull_succeed=${output}" >> $GITHUB_OUTPUT
106+
107+ - name : Pull noobaa-builder image
108+ id : should_build_builder
109+ if : ${{steps.should_build_base.outputs.should_build == 'true' ||
110+ steps.pull_base_image.outputs.pull_succeed == 'false'}}
111+ run : |
112+ output=true
113+ for i in $(seq 0 ${{ steps.prep.outputs.pull_tries }})
114+ do
115+ date=$(date -d "${i} days ago" +'%Y%m%d')
116+ builder_tag="quay.io/${{ steps.prep.outputs.buildertags }}${date}"
117+ echo "Trying to pull ${builder_tag}"
118+ docker pull ${builder_tag} || continue
119+ echo "Successfully pulled ${builder_tag} from quay.io"
120+ docker tag ${builder_tag} noobaa-builder
121+ output=false
122+ break
123+ done
124+ echo "should_build=${output}" >> $GITHUB_OUTPUT
125+
126+ - name : Build noobaa-base image
127+ if : ${{steps.should_build_base.outputs.should_build == 'true' ||
128+ steps.pull_base_image.outputs.pull_succeed == 'false'}}
129+ run : |
130+ if [ "${{ steps.should_build_builder.outputs.should_build }}" = 'false' ]; then
131+ flags="-o builder"
132+ fi
133+ make base ${flags}
134+
135+ - name : Build noobaa and tester images
136+ run : make tester -o base
53137
54138 - name : create docker artifact
55139 run : |
56140 docker save --output noobaa.tar noobaa
57141 docker save --output noobaa-tester.tar noobaa-tester
58142
59- - name : upload noobaa docker image
143+ - name : Upload noobaa docker image
60144 uses : actions/upload-artifact@v4
61145 with :
62146 name : noobaa-image
63147 path : noobaa.tar
64148 retention-days : " 1"
65149
66- - name : upload noobaa-tester docker image
150+ - name : Upload noobaa-tester docker image
67151 uses : actions/upload-artifact@v4
68152 with :
69153 name : noobaa-tester
0 commit comments