Diolor
Diolor

Reputation: 13450

Docker GitHub actions with parameters on build step

I am looking if it's possible to build a docker container from a Dockerfile with args.

The purpose is to have a dynamic "FROM" in the Dockerfile. So in the FROM circleci/android:api-28, the api-28 to be a parameter

So for a constant given Dockerfile:

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

ENTRYPOINT [ "/entrypoint.sh" ]

Github actions build the following image:

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"

Does Github Actions allow environment params or arg params on that build step?

The goal is the Action consumer to use a different docker container tag, if he desires.

Upvotes: 1

Views: 2186

Answers (1)

Sarah Abderemane
Sarah Abderemane

Reputation: 606

I cannot comment to ask questions due to my reputation but I'll try to answer.

I don't know your workflow but if I understand well, you can use args keyword and also entrypoint like that :

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

I really don't know if it will work like that, but maybe this documentation can help you.

Upvotes: 1

Related Questions