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

Invalid Envronment Variable #89

Open
cybrknght opened this issue Jan 8, 2025 · 0 comments
Open

Invalid Envronment Variable #89

cybrknght opened this issue Jan 8, 2025 · 0 comments

Comments

@cybrknght
Copy link

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 protected]
          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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant