Skip to content

How to use Docker tag in a following step ? #140

Description

@Lucas-C

Behaviour

From this README.md, steps.meta.outputs.tags is typed as a String.

However, when trying to use the Docker image built in a following step,
when a new image as been built,
steps.meta.outputs.tags value seems to be <image>:<tag>\n<image>:latest

This \n character causes calls to docker run ... ${{ steps.meta.outputs.tags }} to fail,
as the CI shell interprets the string following the newline as a command that does not exist.

Steps to reproduce this issue

  1. Clone https://github.com/voyages-sncf-technologies/vboard
  2. Create a new tag
  3. Observe the Actions pipeline result

Expected behaviour

I tried to use ${{ steps.meta.outputs.tags[0] }} instead,
but this gets inetrpreted as an empty string (on non-tag builds at least).

Actual behaviour

Neither ${{ steps.meta.outputs.tags }} nor ${{ steps.meta.outputs.tags[0] }}
can actually be used in a docker command following usage of docker/metadata-action@v3 & docker/build-push-action@v2

Configuration

  docker-build-push-ws:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: docker/metadata-action@v3
        id: meta
        with:
          images: vboard/vboard-ws
      - uses: docker/login-action@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - uses: docker/build-push-action@v2
        with:
          context: vboard-ws
          push: ${{ startsWith(github.ref, 'refs/tags/') }}
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
      - name: Validating the image built can start without any error
        run: docker run -e SPRING_PROFILES_ACTIVE=test -e EXIT_AFTER_INIT=true ${{ steps.meta.outputs.tags }}

Logs

vboard-build-3883855145.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions