首页 > 解决方案 > 在构建步骤中使用参数的 Docker GitHub 操作

问题描述

我正在寻找是否可以从带有 args 的 Dockerfile 构建一个 docker 容器。

目的是在 Dockerfile 中有一个动态的“FROM”。所以在 中FROM circleci/android:api-28api-28是一个参数

因此,对于给定的 Dockerfile 常量:

FROM circleci/android:api-28    
COPY entrypoint.sh /entrypoint.sh    
RUN sudo chmod +x entrypoint.sh    

ENTRYPOINT [ "/entrypoint.sh" ]

Github 操作构建以下图像:

Build Diolor/Android-build-action@master2m 8s
Successfully tagged 2e4e3a:89928963f88542989ff9d771e524d2d6
Build container for action use: '/home/runner/work/_actions/Diolor/Android-build-action/master/Dockerfile'.
/usr/bin/docker build -t 2e4e3a:89928963f88542989ff9d771e524d2d6 "/home/runner/work/_actions/Diolor/Android-build-action/master"

Github Actions 是否允许该构建步骤中的环境参数或 arg 参数?

目标是 Action 消费者可以根据需要使用不同的 docker 容器标签。

标签: dockergithub-actions

解决方案


由于我的声誉,我无法评论提问,但我会尽力回答。

我不知道您的工作流程,但如果我理解得很好,您可以使用 args 关键字和类似的入口点:

steps:
  - name: It does something 
    uses: circleci/android:api-28
    with:
      entrypoint: /entrypoint.sh
      args: |
         COPY entrypoint.sh /entrypoint.sh
         RUN sudo chmod +x entrypoint.sh

我真的不知道它是否会这样工作,但也许这个文档可以帮助你


推荐阅读