Syntax error for passing env secrets

hello all,
i getting the following error,

failed to process "${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}": syntax error: bad substitution

and this is how i call the env secret.

          NEXT_PUBLIC_DATABASE_CONNECTION: ${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}

it will deploy fine without the need for env in app pre-build (pre-build in NextJS)

this is the github action yml

name: Publish To Heroku With Docker
on:
  push:
    branches: [master]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Dir
        uses: actions/checkout@v2
      - name: Heroku Deployment
        uses: ElayGelbart/Heroku-Auto-Deployment@v1.0.6
        with:
          herokuApiKey: ${{ secrets.HEROKU_API_KEY}}
          herokuAppName: "shopping-cart-6-cd"
          # herokuAppName: ${{ secrets.HEROKU_APP_NAME}}
          useDocker: true 
          # NODE_ENV: production
          NEXT_PUBLIC_DATABASE_CONNECTION: ${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}
          NEXT_PUBLIC_JWT_TOKEN_SECRET: ${{secrets.NEXT_PUBLIC_JWT_TOKEN_SECRET}}
          NEXT_PUBLIC_PAYPAL_CLIENT_ID: ${{secrets.NEXT_PUBLIC_PAYPAL_CLIENT_ID}}
          NEXT_PUBLIC_PAYPAL_SECRET: ${{secrets.NEXT_PUBLIC_PAYPAL_SECRET}}
          NEXT_PUBLIC_CLOUDINARY_NAME: ${{secrets.NEXT_PUBLIC_CLOUDINARY_NAME}}
          NEXT_PUBLIC_API_KEY: ${{secrets.NEXT_PUBLIC_API_KEY}}
          NEXT_PUBLIC_API_SECRET: ${{secrets.NEXT_PUBLIC_API_SECRET}}
          NEXT_PUBLIC_GOOGLE_MAP_API: ${{secrets.NEXT_PUBLIC_GOOGLE_MAP_API}}
        env:
          # NODE_ENV: production
          NEXT_PUBLIC_DATABASE_CONNECTION: ${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}
          NEXT_PUBLIC_JWT_TOKEN_SECRET: ${{secrets.NEXT_PUBLIC_JWT_TOKEN_SECRET}}
          NEXT_PUBLIC_PAYPAL_CLIENT_ID: ${{secrets.NEXT_PUBLIC_PAYPAL_CLIENT_ID}}
          NEXT_PUBLIC_PAYPAL_SECRET: ${{secrets.NEXT_PUBLIC_PAYPAL_SECRET}}
          NEXT_PUBLIC_CLOUDINARY_NAME: ${{secrets.NEXT_PUBLIC_CLOUDINARY_NAME}}
          NEXT_PUBLIC_API_KEY: ${{secrets.NEXT_PUBLIC_API_KEY}}
          NEXT_PUBLIC_API_SECRET: ${{secrets.NEXT_PUBLIC_API_SECRET}}
          NEXT_PUBLIC_GOOGLE_MAP_API: ${{secrets.NEXT_PUBLIC_GOOGLE_MAP_API}}
  


this is the Dockerfile

# Install dependencies only when needed
FROM node:16-alpine AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.

RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci 

FROM node:16-alpine AS builder 


ARG NEXT_PUBLIC_DATABASE_CONNECTION 

ENV NEXT_PUBLIC_DATABASE_CONNECTION: ${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}
ENV NEXT_PUBLIC_PAYPAL_CLIENT_ID: ${{secrets.NEXT_PUBLIC_PAYPAL_CLIENT_ID}}
ENV NEXT_PUBLIC_PAYPAL_SECRET: ${{secrets.NEXT_PUBLIC_PAYPAL_SECRET}}
ENV NEXT_PUBLIC_CLOUDINARY_NAME: ${{secrets.NEXT_PUBLIC_CLOUDINARY_NAME}}
ENV NEXT_PUBLIC_API_KEY: ${{secrets.NEXT_PUBLIC_API_KEY}}
ENV NEXT_PUBLIC_API_SECRET: ${{secrets.NEXT_PUBLIC_API_SECRET}}
ENV NEXT_PUBLIC_GOOGLE_MAP_API: ${{secrets.NEXT_PUBLIC_GOOGLE_MAP_API}}
ENV NEXT_PUBLIC_JWT_TOKEN_SECRET: ${{secrets.NEXT_PUBLIC_JWT_TOKEN_SECRET}}


WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN npm run build && npm install --production --ignore-scripts --prefer-offline 


# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app


ARG NEXT_PUBLIC_DATABASE_CONNECTION 

# ENV NODE_ENV = production
    
ENV NEXT_PUBLIC_DATABASE_CONNECTION: ${{ secrets.NEXT_PUBLIC_DATABASE_CONNECTION  }}
ENV NEXT_PUBLIC_PAYPAL_CLIENT_ID: ${{secrets.NEXT_PUBLIC_PAYPAL_CLIENT_ID}}
ENV NEXT_PUBLIC_PAYPAL_SECRET: ${{secrets.NEXT_PUBLIC_PAYPAL_SECRET}}
ENV NEXT_PUBLIC_CLOUDINARY_NAME: ${{secrets.NEXT_PUBLIC_CLOUDINARY_NAME}}
ENV NEXT_PUBLIC_API_KEY: ${{secrets.NEXT_PUBLIC_API_KEY}}
ENV NEXT_PUBLIC_API_SECRET: ${{secrets.NEXT_PUBLIC_API_SECRET}}
ENV NEXT_PUBLIC_GOOGLE_MAP_API: ${{secrets.NEXT_PUBLIC_GOOGLE_MAP_API}}
ENV NEXT_PUBLIC_JWT_TOKEN_SECRET: ${{secrets.NEXT_PUBLIC_JWT_TOKEN_SECRET}}

RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001

# You only need to copy next.config.js if you are NOT using the default configuration
COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

# Automatically leverage output traces to reduce image size 
# https://nextjs.org/docs/advanced-features/output-file-tracing
 COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 8000

ENV PORT 8000 

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1

CMD ["npm", "run", "start"]

what is wrong???
regards.

Docker does not support that variable substitution syntax. It looks like you quoted the other variable from the yaml but it is more likely that you got the error message during docker build. If those variables were supposed to be replaced before the build, then it is a GitHub actions issue, not Docker. Unfortunatelly I don’t use GitHub actions so I don’t know how that should work.