added debug cmd #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: All in One Test | |
on: | |
push: | |
branches: | |
- feature/docker-image | |
# define the workflow that will trigger this workflow to run | |
# workflow_run: | |
# workflows: [sharing data in a workflow] | |
# types: | |
# - completed | |
# allow the workflow to run manually with version as input | |
# workflow_dispatch: | |
# inputs: | |
# build_version: | |
# description: 'Crawler Version Number' | |
# required: false | |
# type: string | |
# manually set the version number of testing purpose | |
env: | |
manual_build_version: 2.99 | |
jobs: | |
# job to build the base crawler image | |
build-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: feature/docker-image | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# download the crawler-info file from the maven build workflow | |
#- name: Download artifact | |
# id: download-artifact | |
# uses: dawidd6/action-download-artifact@v2 | |
# with: | |
# workflow: mvn-build-upload.yml | |
# branch: dk-actions-v4 | |
# name: crawler-info | |
# if_no_artifact_found: fail | |
# check which version value whould be used | |
- name: check condition | |
uses: haya14busa/action-cond@v1 | |
id: version_value_check | |
with: | |
cond: $manual_build_version == '' | |
#cond: ${{ inputs.build_version == '' }} | |
if_true: $(cat pom.xml | grep -m1 "version" | sed 's/<.*>\(.*\)<.*>/\1/' | sed 's/^[ ]*//g') | |
#if_false: ${{ inputs.build_version }} | |
if_false: $manual_build_version | |
# assign value to env variable for later use | |
- name: Use conditional value | |
run: echo "version=${{ steps.version_value_check.outputs.value }}" >> $GITHUB_ENV | |
# print the value of the env version variable for debugging use | |
- name: print the value of GITHUB_ENV:version | |
run: | | |
echo "read-data-version:$(cat pom.xml | grep -m1 "version" | sed 's/<.*>\(.*\)<.*>/\1/' | sed 's/^[ ]*//g')" | |
#echo "input-version: ${{ inputs.build_version }}" | |
echo "input-version: $manual_build_version" | |
echo "GITHUB_ENV_Version: ${{env.version}}" | |
# build the crawler base docker image | |
- name: Build docker base image | |
run: | | |
pwd | |
ls | |
docker build . --file .github/docker-files/Dockerfile-base --tag ${{env.version}}-crawler-base | |
# build the crawler latest docker image | |
#- name: Build docker latest image | |
# run: docker build . --file Dockerfile-base --tag latest | |
# update the FROM statement in Dockerfile with the right version number | |
- name: Update Dockerfile with version to build | |
run: sed -i 's/replace-this-with-real-version/${{env.version}}/g' ./.github/docker-files/Dockerfile-com | |
### Repeat this section of code to build image for new committers, make sure the sed cmd | |
### is finding the right lines to replace | |
- name: Build new es committer image | |
run: | | |
cp ./.github/docker-files/Dockerfile-com ./.github/docker-files/Dockerfile-com-es | |
sed -i 's/replace-this-with-committer-files-in-dockerfile/mkdir .\/es-folder/g' ./.github/docker-files/Dockerfile-com-es | |
more ./.github/docker-files/Dockerfile-com-es | |
# docker build . --file ./Dockerfile-com --build-arg build_version=${{env.version}} --tag ${{env.version}}-crawler-es | |
### Repeat section | |
- name: Build new solr committer image | |
run: | | |
cp ./.github/docker-files/Dockerfile-com ./.github/docker-files/Dockerfile-com-solr | |
sed -i 's/replace-this-with-committer-files-in-dockerfile/mkdir .\/solr-folder/g' ./.github/docker-files/Dockerfile-com-solr | |
more ./.github/docker-files/Dockerfile-com-solr | |
#docker build . --file ./Dockerfile-com --build-arg build_version=${{env.version}} --tag ${{env.version}}-crawler-solr | |
#docker image ls -a | |
# login to Dockerhub | |
# - name: Login to Docker Hub | |
# uses: docker/login-action@v3 | |
# with: | |
# username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
# password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
# ### For additional committers, repeat the docker image tag and docker push cmd | |
# # Tag and push images onto Dockerhub repo | |
# - name: Push images to Dockerhub | |
# run: | | |
# #docker image tag latest norconex/crawler:latest | |
# docker image tag ${{env.version}}-crawler-base norconex/crawler:${{env.version}}-crawler-base | |
# docker image tag ${{env.version}}-crawler-es norconex/crawler:${{env.version}}-crawler-es | |
# docker image tag ${{env.version}}-crawler-solr norconex/crawler:${{env.version}}-crawler-solr | |
# #docker push norconex/crawler:latest | |
# docker push norconex/crawler:${{env.version}}-crawler-base | |
# docker push norconex/crawler:${{env.version}}-crawler-es | |
# docker push norconex/crawler:${{env.version}}-crawler-solr |