[英]Is it possible to use GitHub Action inputs inside the Dockerfile?
我创建了一个 GitHub 操作并将输入参数传递给该操作。 我在 bash 脚本中使用这些参数,该脚本由Dockerfile
。 但是,可以在Dockerfile
使用这些输入中的Dockerfile
吗?
具体来说,我试图使 python 版本成为变量输入。 Dockerfile
是:
FROM python:3
RUN pip install flake8
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
我希望第一行在哪里
FROM python:<github_action_input_arg>
首先,我建议你使用docker/build-push-action@v2
。 然后在管道中,您可以使用 next 将参数从 github 操作传递到 Dockerfile:
-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: $your_account/$your_repo
build-args: |
github_action_input_arg=xxx
当然,对于Dockerfile
,您应该更改为下一个:
ARG github_action_input_arg
FROM python:${github_action_input_arg}
您可以参考理解-如何-arg-and-from-interact & build-push-action 。 如果您的意思是您是自己操作的所有者,则还可以参考build-push-action
以了解它如何处理此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.