diff --git a/.github/workflows/push-docker-base-image.yml b/.github/workflows/push-docker-base-image.yml index a7d4c14..48fcb2c 100644 --- a/.github/workflows/push-docker-base-image.yml +++ b/.github/workflows/push-docker-base-image.yml @@ -13,18 +13,50 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 + - name: Check if code relevant to executor has changed + uses: dorny/paths-filter@v2 + id: check + with: + filters: | + changed: + - src/options/generate/static_files/base_image/** + + - name: Get base image tag + if: steps.check.outputs.changed == 'true' + shell: bash + run: | + FILE='scr/constants.py' + VERSION=$(sed -n '/DOCKER_BASE_IMAGE_VERSION =/p' $FILE | cut -d \' -f2) + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Check that tag isn't used already for the docker base image + if: steps.check.outputs.changed == 'true' + env: + VERSION: ${{ env.VERSION }} + shell: bash + run: | + if jina hub pull jinahub+docker://jinaai/gpt-dev/$VERSION; then + echo "Executor version/tag is used already. Please update the tag" + exit 1 + else + echo "Executor version/tag isn't used already, continue to build..." + fi + - name: Set up Docker Buildx + if: steps.check.outputs.changed == 'true' uses: docker/setup-buildx-action@v1 - name: Login to Docker Hub + if: steps.check.outputs.changed == 'true' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_DEVBOT_USER }} password: ${{ secrets.DOCKERHUB_DEVBOT_PWD }} - name: Build and Push Docker Image + if: steps.check.outputs.changed == 'true' uses: docker/build-push-action@v2 with: context: src/options/generate/static_files/base_image push: true - tags: jinaai/gpt-dev:latest \ No newline at end of file + tags: jinaai/gpt-dev:$VERSION \ No newline at end of file diff --git a/src/constants.py b/src/constants.py index 08833b4..ef527c3 100644 --- a/src/constants.py +++ b/src/constants.py @@ -1,3 +1,5 @@ +DOCKER_BASE_IMAGE_VERSION = '0.0.1' + EXECUTOR_FILE_NAME = '__init__.py' IMPLEMENTATION_FILE_NAME = 'microservice.py' TEST_EXECUTOR_FILE_NAME = 'test_microservice.py' @@ -51,3 +53,4 @@ LANGUAGE_PACKAGES = [ 'pattern', 'polyglot', 'pytorch-transformers', 'rasa', 'sentence-transformers', 'spacy', 'stanza', 'summarizer', 'sumy', 'textblob', 'textstat', 'transformers' ] +