Skip to content

Commit e1e16b0

Browse files
eseikeralexiri
authored andcommitted
Support multi-stage build Dockerfile for prepare-build
closes #69
1 parent 3fc6b81 commit e1e16b0

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

.github/actions/prepare-build/action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ runs:
5757
# Extract the last FROM image using Python
5858
upstream=$(python3 - << 'EOF'
5959
from dockerfile_parse import DockerfileParser
60+
from dockerfile_parse.parser import image_from
6061
with open("${{ inputs.containerfile }}", "r") as f:
6162
dfp = DockerfileParser(fileobj=f)
62-
froms = [s['value'].split()[0] for s in dfp.structure if s['instruction'] == 'FROM']
63-
print(froms[-1])
63+
froms = [image_from(s['value']) for s in dfp.structure if s['instruction'] == 'FROM']
64+
upstream = froms[-1][0]
65+
for image, name in reversed(froms):
66+
if name == upstream:
67+
upstream = image
68+
print(upstream)
6469
EOF
6570
)
6671
echo "upstream-image=$upstream" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)