format test #65
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: "7.77.778" | |
committer_types: "es solr db" | |
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 == '9.99' | |
# #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 | |
# check which value should be used as the version value | |
- name: Use conditional value | |
run: | | |
if [[ $manual_build_version == '' ]]; then | |
echo "tmp_version=$(cat pom.xml | grep -m1 "version" | sed 's/<.*>\(.*\)<.*>/\1/' | sed 's/^[ ]*//g')" >> $GITHUB_ENV | |
else | |
echo "tmp_version=$manual_build_version" >> $GITHUB_ENV | |
fi | |
#run: echo "version=${{ steps.version_value_check.outputs.value }}" >> $GITHUB_ENV | |
# echo "tmp_version=$(cat pom.xml | grep -m1 "version" | sed 's/<.*>\(.*\)<.*>/\1/' | sed 's/^[ ]*//g')" >> $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_TMP_Version: ${{ env.tmp_version }}" | |
# convert the string to lower case for SNAPSHOT build | |
- name: convert string to lowercase | |
id: string | |
uses: ASzc/change-string-case-action@v1 | |
with: | |
string: ${{ env.tmp_version }} | |
# assign the lowercase value back to an variable for later use | |
- run: | | |
echo "version=${{ steps.string.outputs.lowercase }}" >> $GITHUB_ENV | |
#echo "version=${{ steps.string.outputs.lowercase }}" >> $GITHUB_ENV | |
echo "lowercase: ${{ steps.string.outputs.lowercase }}" | |
# debug use only | |
- run: | | |
echo "GITHUB_ENV_Version: ${{ env.version }}" | |
# build the crawler base docker image | |
- name: Build docker base image | |
run: | | |
pwd | |
ls -a | |
docker build . --file .github/workflows/docker-files/Dockerfile-base --tag ${{env.version}}-crawler-base | |
# 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/workflows/docker-files/Dockerfile-com | |
# extract version number from value and assign it to different variables for tagging use | |
- name: Extract version numbers | |
run: | | |
if [[ "${{env.version}}" == *"-snapshot"* ]]; then | |
echo "snapshot_image=${{env.version}}" >> $GITHUB_ENV | |
else | |
# Extract major version | |
echo "major=$(echo ${{env.version}} | cut -d '.' -f 1)" >> $GITHUB_ENV | |
# Extract major_minor version | |
echo "major_minor=$(echo ${{env.version}} | cut -d '.' -f 1-2)" >> $GITHUB_ENV | |
# Extract major_minor_revis version | |
#echo "major_minor_revis=$(echo ${{env.version}} | cut -d '-' -f 1)" >> $GITHUB_ENV | |
fi | |
- name: print extracted version numbers | |
run: | | |
# Print extracted version numbers | |
echo "Major: ${{ env.major }}" | |
echo "Major_Minor: ${{ env.major_minor }}" | |
#echo "Major_Minor_Revis: ${{ env.major_minor_revis }}" | |
echo "Snapshot_Image: ${{ env.snapshot_image }}" | |
- name: Build new es committer image | |
run: | | |
for type in $committer_types; do | |
com_type=$type | |
cp .github/workflows/docker-files/Dockerfile-com .github/workflows/docker-files/Dockerfile-com-$type | |
sed -i 's/replace-this-with-committer-files-in-dockerfile/mkdir .\/${com_type}-folder/g' .github/workflows/docker-files/Dockerfile-com-$type | |
more .github/workflows/docker-files/Dockerfile-com-$type | |
docker build . --file .github/workflows/docker-files/Dockerfile-com-$type --build-arg build_version=${{env.version}} --tag ${{env.version}}-crawler-$type | |
docker image ls -a | |
done | |
# ### 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/workflows/docker-files/Dockerfile-com .github/workflows/docker-files/Dockerfile-com-es | |
# sed -i 's/replace-this-with-committer-files-in-dockerfile/mkdir .\/es-folder/g' .github/workflows/docker-files/Dockerfile-com-es | |
# more .github/workflows/docker-files/Dockerfile-com-es | |
# docker build . --file .github/workflows/docker-files/Dockerfile-com-es --build-arg build_version=${{env.version}} --tag ${{env.version}}-crawler-es | |
# docker image ls -a | |
# ### Repeat section | |
# - name: Build new solr committer image | |
# run: | | |
# cp .github/workflows/docker-files/Dockerfile-com .github/workflows/docker-files/Dockerfile-com-solr | |
# sed -i 's/replace-this-with-committer-files-in-dockerfile/mkdir .\/solr-folder/g' .github/workflows/docker-files/Dockerfile-com-solr | |
# more .github/workflows/docker-files/Dockerfile-com-solr | |
# docker build . --file .github/workflows/docker-files/Dockerfile-com-solr --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: Tag and Push images to Dockerhub | |
# run: | | |
# #committer_type="es solr db" | |
# # check if it is a snapshot build, if not, upload different favor of images | |
# if [[ "${{env.version}}" != *"-snapshot"* ]]; then | |
# docker image tag ${{env.version}}-crawler-base norconex/crawler:latest | |
# docker image tag ${{env.version}}-crawler-base norconex/crawler:${{env.major}} | |
# docker image tag ${{env.version}}-crawler-base norconex/crawler:${{env.major_minor}} | |
# docker image tag ${{env.version}}-crawler-base norconex/crawler:${{env.version}} | |
# for type in $committer_types; do | |
# docker image tag ${{env.version}}-crawler-es norconex/crawler:${{env.major}}-$type | |
# docker image tag ${{env.version}}-crawler-es norconex/crawler:${{env.major_minor}}-$type | |
# docker image tag ${{env.version}}-crawler-es norconex/crawler:${{env.version}}-$type | |
# done | |
# docker image ls -a | |
# # docker image tag ${{env.version}}-crawler-solr norconex/crawler:${{env.major}}-solr | |
# # docker image tag ${{env.version}}-crawler-solr norconex/crawler:${{env.major_minor}}-solr | |
# # docker image tag ${{env.version}}-crawler-solr norconex/crawler:${{env.version}}-solr | |
# # # upload to dockerhub | |
# # docker push norconex/crawler:latest | |
# # docker push norconex/crawler:${{env.major}} | |
# # docker push norconex/crawler:${{env.major_minor}} | |
# # docker push norconex/crawler:${{env.version}} | |
# # docker push norconex/crawler:${{env.major}}-es | |
# # docker push norconex/crawler:${{env.major_minor}}-es | |
# # docker push norconex/crawler:${{env.version}}-es | |
# # docker push norconex/crawler:${{env.major}}-solr | |
# # docker push norconex/crawler:${{env.major_minor}}-solr | |
# # docker push norconex/crawler:${{env.version}}-solr | |
# echo "Base, and committers images uploaded!" | |
# else | |
# # tag the local images with repo inform for upload use | |
# docker image tag ${{env.version}}-crawler-base norconex/crawler:${{env.version}} | |
# docker image tag ${{env.version}}-crawler-es norconex/crawler:${{env.version}}-es | |
# docker image tag ${{env.version}}-crawler-solr norconex/crawler:${{env.version}}-solr | |
# # upload tagged images to dockerhub | |
# docker push norconex/crawler:${{env.version}} | |
# docker push norconex/crawler:${{env.version}}-es | |
# docker push norconex/crawler:${{env.version}}-solr | |
# echo "snapshot uploaded!" | |
# fi |