diff --git a/.github/actions/get-docker-image-path/action.yml b/.github/actions/get-docker-image-path/action.yml new file mode 100644 index 0000000..f75cde4 --- /dev/null +++ b/.github/actions/get-docker-image-path/action.yml @@ -0,0 +1,29 @@ +name: 'Detect Dockerfile location' +description: 'Decides which location the docker file is located at' +inputs: + default-directory: + description: 'Module name for Gradle build' + required: false + dockerfile-path: + description: 'An option to override the default dockerfile location, if none supplied the return value would be ${{ inputs.default-directory}}/Dockerfile' + required: false +outputs: + location: + description: the location of the dockerfile that should be used + value: ${{ steps.dockerfile.outputs.location }} + +runs: + using: 'composite' + steps: + - name: Find Dockerfile Location + id: dockerfile + shell: bash + run: | + if [ -n "${{ inputs.dockerfile-path }}" ]; then + echo "location=${{ inputs.dockerfile-path }}" >> $GITHUB_OUTPUT + elif [-n "${{ inputs.default-directory }}"]; then + echo "location=${{ inputs.default-directory }}/Dockerfile" >> $GITHUB_OUTPUT + else + echo "Both dockerfile-path and default-directory are empty" + exit 1 + fi diff --git a/.github/workflows/ci-composite-actions.yml b/.github/workflows/ci-composite-actions.yml index 5cc5d1f..9dd52e6 100644 --- a/.github/workflows/ci-composite-actions.yml +++ b/.github/workflows/ci-composite-actions.yml @@ -25,3 +25,15 @@ jobs: uses: yonatankarp/github-actions/.github/actions/build-jar-artifact@main with: tag: "test-tag" + + - name: "[test] - Get Dockrfile for module - use dockerfile override" + uses: yonatankarp/github-actions/.github/actions/get-docker-image-path@extract-dockerfile-location +# with: +# module-name: "" +# dockerfile-path: "dockerfile-location" +# +# - name: "[test] Get Dockrfile for module - fallback to module" +# uses: yonatankarp/github-actions/.github/actions/get-docker-image-path@extract-dockerfile-location +# with: +# module-name: "test-tag" +# dockerfile-path: ""