Closed 1xo2 closed 2 years ago
it will be great if you could give an example how to pass env secret, in my case without the env its working as expected.
this is the error i get
failed to process "${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}": syntax error: bad substitution
the yml
`name: Publish To Heroku With Docker on: push: branches: [master]
jobs: publish: runs-on: ubuntu-latest steps:
name: Heroku Deployment uses: ElayGelbart/Heroku-Auto-Deployment@v1.0.6 with: herokuApiKey: ${{ secrets.HEROKU_API_KEY}} herokuAppName: "shopping-cart-6-cd"
useDocker: true NEXT_PUBLIC_DATABASE_CONNECTION: ${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}} env: NEXT_PUBLIC_DATABASE_CONNECTION: ${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}
`
the Dockerfile
` FROM node:16-alpine AS deps 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}}
WORKDIR /app COPY . . COPY --from=deps /app/node_modules ./node_modules RUN npm run build && npm install --production --ignore-scripts --prefer-offline
FROM node:16-alpine AS runner WORKDIR /app
ENV NEXT_PUBLIC_DATABASE_CONNECTION: ${{ secrets.NEXT_PUBLIC_DATABASE_CONNECTION }}
RUN addgroup -g 1001 -S nodejs RUN adduser -S nextjs -u 1001
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
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 8000
ENV PORT 8000
CMD ["npm", "run", "start"] `
looks like a bug unrelated to this GH Action, Issue CLosed
it will be great if you could give an example how to pass env secret, in my case without the env its working as expected.
this is the error i get
failed to process "${{secrets.NEXT_PUBLIC_DATABASE_CONNECTION}}": syntax error: bad substitution
the yml
`name: Publish To Heroku With Docker on: push: branches: [master]
jobs: publish: runs-on: ubuntu-latest steps:
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}}
`
the Dockerfile
` FROM node:16-alpine AS deps 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}}
WORKDIR /app COPY . . COPY --from=deps /app/node_modules ./node_modules RUN npm run build && npm install --production --ignore-scripts --prefer-offline
FROM node:16-alpine AS runner WORKDIR /app
ARG NEXT_PUBLIC_DATABASE_CONNECTION
ENV NEXT_PUBLIC_DATABASE_CONNECTION: ${{ secrets.NEXT_PUBLIC_DATABASE_CONNECTION }}
RUN addgroup -g 1001 -S nodejs RUN adduser -S nextjs -u 1001
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
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 8000
ENV PORT 8000
CMD ["npm", "run", "start"] `