Skip to content

Invalid Envronment Variable #89

Description

I'm using the workflow file below.
But I'm receiving the following error on the "Run Azure/aci-deploy@v1" step:

Error: Error: The environment variable name in container 'test' of container group 'test' is invalid. A valid environment variable name must start with alphabetic character or '_', followed by a string of alphanumeric characters or '_' (e.g. 'my_name',  or 'MY_NAME',  or 'MyName').

From what I can tell, it is either a problem with a multiline string, spaces in the environment variable or both. I have tried surrounding the environment variable with single and double quotes. I even tried to save it as a multiline Github secret.

Any guidance or indications of what could be the problem are appreciated.

name: Create and publish a Docker image

on:
  push:
    branches:
      - main
    paths:
      - test/**
  workflow_dispatch:


env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}/test
  CONTAINER_VERSION: ${{ github.env.CONTAINER_VERSION || 'latest' }}


jobs:
  build-and-push-image:
    environment: production
    runs-on: ubuntu-latest

    permissions:
      contents: read
      packages: write
      id-token: write

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - 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 }}
          tags: |
            # set latest tag for default branch (by default = 'main')
            type=raw,value=latest,enable={{is_default_branch}}

      - name: Build and push Docker image
        uses: docker/build-push-action@v5
        with:
          context: "{{defaultContext}}:test"
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          secrets: |
            "TEST_ACCOUNT_ID=${{ secrets.TEST_ACCOUNT_ID }}"
            "TEST_LICENSE_KEY=${{ secrets.TEST_LICENSE_KEY }}"
            "TEST_EDITION_IDS=${{ secrets.TEST_EDITION_IDS }}"

      - name: First Env Variable
        run: |
          MULTI_LINES_TEXT="[first]
          auth_method = ClientSecret
          client_id = ${{ secrets.MSGRAPH_CLIENT_ID }}
          client_secret = ${{ secrets.MSGRAPH_CLIENT_SECRET }}
          allow_unencrypted_storage = True
          mailbox = email@company.com
          tenant_id = ${{ secrets.AZURE_TENANT_ID }}"

          echo "FIRST_CONFIG<<EOF" >> $GITHUB_ENV
          echo "$MULTI_LINES_TEXT" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

      - name: Second URL Variable
        run: |
          echo SECOND_URL="https://second:${{ secrets.SECOND_PASSWORD }}@test.es.us-east-2.aws.elastic-cloud.com:9243/" >> $GITHUB_ENV

      - name: Azure Login
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZURE_CLIENT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID}}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}

      - uses: Azure/aci-deploy@v1
        with:
          name: test
          location: 'central us'
          resource-group: test-container
          dns-name-label: test-container
          image: ${{ env.REGISTRY }}/company-com/it-test:${{ env.CONTAINER_VERSION }}
          registry-login-server: ${{ env.REGISTRY }}
          registry-username: gh-automation
          registry-password: ${{ secrets.GHCR_PASSWORD }}
          cpu: 2
          memory: 2
          ports: 9998
          protocol: UDP
          environment-variables: TEST_ONE=true TEST_TWO=true
          secure-environment-variables: SECOND_URL=${{ env.SECOND_URL }} FIRST_CONFIG=${{ env.FIRST_CONFIG }}

      - name: Azure logout
        run: |
          az logout

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions