compose-action icon indicating copy to clipboard operation
compose-action copied to clipboard

services.service_name.env_file.0 must be a string

Open mihalt opened this issue 1 year ago • 3 comments

I am trying to do something like this

name: Django CI

on:
  push:
    branches: [ "production", "developing" ]
  pull_request:
    branches: [ "production", "developing" ]
  workflow_dispatch:

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}

jobs:
  testing:
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write

    steps:
      - uses: actions/checkout@v4
      - uses: hoverkraft-tech/[email protected]
      - name: testing
        run: "docker compose exec app pytest"

      - name: Log in to the Container registry
        uses: docker/login-action@v3
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

      - name: Build and push Docker image
        uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

And I get an error like Error: compose up failed {"exitCode":15,"err":"validating /home/runner/work/.../docker-compose.yml: services.app.env_file.0 must be a string\n","out":""} and Error: compose down failed [object Object]

In docker-compose.yml this service strings looks like:

  app:
    env_file:
      - path: ".env"
        required: true
      - path: "overwrite.env"
        required: false

mihalt avatar Mar 27 '24 18:03 mihalt

@mihalt the required attribute is available with Docker Compose version 2.24.0 or later. (https://docs.docker.com/compose/compose-file/05-services/#env_file). From what I now Github runners are using docker compose2.23.3

neilime avatar Apr 03 '24 10:04 neilime

@mihalt the required attribute is available with Docker Compose version 2.24.0 or later. (https://docs.docker.com/compose/compose-file/05-services/#env_file). From what I now Github runners are using docker compose2.23.3

so, what should I do in this case? manually update docker compose on github runner by separate apt install command?

mihalt avatar Apr 03 '24 12:04 mihalt

Yes this is a workaround, the best thing will be that the action provides a way to ensure a specific version. I'm creating a issue to track this feature: https://github.com/hoverkraft-tech/compose-action/issues/68

neilime avatar Apr 03 '24 12:04 neilime

This issue is stale

github-actions[bot] avatar Jun 03 '24 02:06 github-actions[bot]