Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-arg not support multiline variable #374

Closed
k0st1an opened this issue May 29, 2021 · 5 comments
Closed

build-arg not support multiline variable #374

k0st1an opened this issue May 29, 2021 · 5 comments

Comments

@k0st1an
Copy link

k0st1an commented May 29, 2021

Troubleshooting

I need to save a multiline variable to a file. But the result is a file with only one line. secrets.DEPLOY_KEY - multiline variable.

      - name: Build SCM container image
        uses: docker/build-push-action@v2
        with:
          push: true
          build-args: |
            VAULT_PASSWORD=${{ secrets.ANSIBLE_VAULT_PASSWORD }}
            PRIVATE_KEY=${{ secrets.DEPLOY_KEY }}

Dockerfile:

ARG VAULT_PASSWORD
ARG PRIVATE_KEY
ENV PASSWORD $VAULT_PASSWORD
ENV KEY $PRIVATE_KEY
...
RUN echo "$PASSWORD" > /etc/vault.txt && \
    chmod 0600 /etc/vault.txt
RUN echo "$KEY" > /root/.ssh/id_rsa && \
    chmod 0600 /root/.ssh/id_rsa

image

Expected behaviour

cat /root/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----
...
...

Actual behaviour

cat /root/.ssh/id_rsa
-----BEGIN OPENSSH PRIVATE KEY-----

One line only.

PS

Working version if done manually: concourse/docker-image-resource#79 (comment)

@mindflayer
Copy link

mindflayer commented Jun 3, 2021

I've just had the same problem. At the moment I fixed pointing uses to docker/build-push-action@v2.4.0.

@crazy-max
Copy link
Member

@k0st1an Like secrets, you need to place the key-value pair between quotes:

      - name: Build SCM container image
        uses: docker/build-push-action@v2
        with:
          push: true
          build-args: |
            "VAULT_PASSWORD=${{ secrets.ANSIBLE_VAULT_PASSWORD }}"
            "PRIVATE_KEY=${{ secrets.DEPLOY_KEY }}"

@mindflayer
Copy link

mindflayer commented Jun 3, 2021

It's still broken in my environment. It acts like if I am not passing the variable. Same code works for v2.4.0.

@crazy-max
Copy link
Member

@mindflayer Can you give me a link to your repo pls?

@mindflayer
Copy link

Can you give me a link to your repo pls?

Nevermind, it was a false alarm and I am sorry for polluting the thread. Two problems at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants