Skip to content

Commit a71d92a

Browse files
committed
Allow building Docker image via script
- callers can pass in the optional variable `docker_build_script` - script should produce a Docker image - if the script variable is set the default Docker image build step isn't executed See exercism/java-test-runner#147 for context
1 parent 0b4b469 commit a71d92a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

.github/workflows/docker-build-push-image.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ on:
1313
default: true
1414
required: false
1515
type: boolean
16+
docker_build_script:
17+
description: "Script that produces a Docker image"
18+
required: false
19+
type: string
1620
provenance:
1721
description: "Generate provenance attestation for the build"
1822
default: true
@@ -95,8 +99,12 @@ jobs:
9599
username: ${{ secrets.AWS_ECR_ACCESS_KEY_ID }}
96100
password: ${{ secrets.AWS_ECR_SECRET_ACCESS_KEY }}
97101

102+
- name: Build Docker image via build script
103+
if: ${{ inputs.docker_build_script && steps.dockerfile-exists.outputs.result == 'true' && (inputs.docker_hub || inputs.aws_ecr)}}
104+
run: ${{ inputs.docker_build_script }}
105+
98106
- name: Build Docker image
99-
if: ${{steps.dockerfile-exists.outputs.result == 'true' && (inputs.docker_hub || inputs.aws_ecr)}}
107+
if: ${{ !inputs.docker_build_script && steps.dockerfile-exists.outputs.result == 'true' && (inputs.docker_hub || inputs.aws_ecr)}}
100108
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
101109
with:
102110
context: .

0 commit comments

Comments
 (0)