[英]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.