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

NuxtUI Pro will not deploy to NuxtHub #430

Open
ratracegrad opened this issue Jan 21, 2025 · 7 comments
Open

NuxtUI Pro will not deploy to NuxtHub #430

ratracegrad opened this issue Jan 21, 2025 · 7 comments

Comments

@ratracegrad
Copy link

I have deployed my app multiple times to NuxtHub. I have added NuxtUI Pro. It will not deploy because of my NuxtUIPro is not being read.

My NuxtUI Pro license is validated.

I have updated my nuthub.yml file to be:

name: Deploy to NuxtHub
on: push

jobs:
  deploy:
    name: "Deploy to NuxtHub"
    runs-on: ubuntu-latest
    environment:
      name: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }}
      url: ${{ steps.deploy.outputs.deployment-url }}
    permissions:
      contents: read
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: Install pnpm
        uses: pnpm/action-setup@v4

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'pnpm'

      - name: Install dependencies
        run: pnpm install

      - name: Build application
        run: pnpm build
        env:
          NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }}

      - name: Deploy to NuxtHub
        uses: nuxt-hub/action@v1
        id: deploy
        with:
          project-key: three-quartiles-4h4d

In my NuxtHub admin in Environments I have my NUXT_UI_PRO_LICENSE and it is deplyed as you can see in this screenshot:

Image

The Deploy to NuxtHub task fails with:

[info] Running with compatibility version `4`
[info] [nuxi] Building for Nitro preset: `cloudflare-pages`
Error:  Missing `NUXT_UI_PRO_LICENSE` license key.
Purchase Nuxt UI Pro at `[https://ui.nuxt.com/pro/pricing`](https://ui.nuxt.com/pro/pricing%60) to build your app in production.
 

Error:  Missing `NUXT_UI_PRO_LICENSE` license key.
Purchase Nuxt UI Pro at `[https://ui.nuxt.com/pro/pricing`](https://ui.nuxt.com/pro/pricing%60) to build your app in production.
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.
@RihanArfan
Copy link
Collaborator

RihanArfan commented Jan 21, 2025

If you're on GitHub's free tier, we can't sync environment variables or secrets from NuxtHub Admin to GitHub since GitHub environments are only available on their paid plans. You can add a repository secret called NUXT_UI_PRO_LICENSE via Repository Settings -> Secrets and variables -> Actions (and also on Dependabot too if you use that), and they'll apply to deployments for both environments.

EDIT: Clarified limitation from GitHub

@DavidSabine
Copy link

I suggest this issue be re-opened.

Reasons:

  1. The solution suggested by @RihanArfan is not reliable. I did as suggested but still could not deploy successfully. Either a detail is missing or the instruction is not appropriate in my case.

  2. This is terrible Customer Experience: your customer works locally with Nuxt UI Pro, makes a personal commitment to integrate it into their Nuxt app, then PAYS MONEY for the key, then tries to deploy to hub.nuxt expecting that the ecosystem is seamless (I mean, why not deploy on Vercel or Netlify except that this is a host specializing in NUXT apps!), then crashes into this obscure limitation.

  3. I was able to successfully deploy after adding finding this strange documentation: https://ui.nuxt.com/pro/getting-started/installation#uiprolicense and I think this CANNOT be the official recommendation?! My repo is currently private, but this is very bad practice to put secrets into plain text config files in the repo.

I would be interested to learn whether @ratracegrad was able to overcome this obstacle? It looks like @RihanArfan quickly closed the issue without learning whether the advice was actionable.

@RihanArfan
Copy link
Collaborator

Hi @DavidSabine, thank you for raising these points. I understand the current requirement requiring updating your GitHub Actions workflow file to reference secrets isn't ideal at all and we're investigating ways to improve this.

We have a guide for using GitHub secrets during build time on our docs - it requires making a modification to your workflow file to utilise the GitHub secret. https://hub.nuxt.com/docs/getting-started/deploy#environment-variables-secrets. If your repo is on a free GitHub account/org, you'll need to follow the steps in my previous reply to set the secret too. Otherwise, setting/updating the secret from NuxtHub Admin will set the secret on GitHub.

It should definitely be possible to deploy Nuxt UI Pro without hardcoding the secret inside your code. In order to investigate your deployment problem, please could you share your GitHub Actions workflow file and I'll take a look.

@RihanArfan RihanArfan reopened this Jan 31, 2025
@DavidSabine
Copy link

Hello @RihanArfan,

My repo is on a free GitHub account, yes.

I read the doc at /docs/getting-started/deploy#env...::

I then:

  1. created the secret at github
  2. added the env variable to nuxthub (and ran nuxthub deploy --no-build to ensure the variable was replicated at cloudflare)
  3. and modified my nuxthub.yml as follows:

Image

Image

Image

You can see VSCode doesn't like the syntax in the yml file - but more importantly, it fails to deploy whether I use npx nuxthub deploy or commit to GitHub (to trigger the action).

@RihanArfan
Copy link
Collaborator

Hmm this is certainly very strange. Your workflow file and secret name appear to be correct. Just to confirm, is the secret under Actions? Also, could you double check the license key is correct?

You can test the license key by setting NUXT_UI_PRO_LICENSE= inside your .env file locally, then running npx nuxthub deploy or npm run build. I suspect local builds are failing due to the lack of license key set when trying to build.

I've tested deploying a Nuxt UI Pro template from scratch successfully.

  1. Created template from https://github.com/nuxt-ui-pro/starter to an org without a subscription
  2. pnpx nuxi module add hub and pushed
  3. Imported to NuxtHub
  4. Added the secret to GitHub
  5. Edited the workflow to use the secret

Image

Image

.github/workflows/nuxthub.yml

name: Deploy to NuxtHub
on: push

jobs:
  deploy:
    name: "Deploy to NuxtHub"
    runs-on: ubuntu-latest
    environment:
      name: ${{ github.ref == 'refs/heads/v3' && 'production' || 'preview' }}
      url: ${{ steps.deploy.outputs.deployment-url }}
    permissions:
      contents: read
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: Install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 9

      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'pnpm'

      - name: Install dependencies
        run: pnpm install

      - name: Build application
        run: pnpm build
        env:
          NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }}

      - name: Deploy to NuxtHub
        uses: nuxt-hub/action@v1
        id: deploy
        with:
          project-key: nuxt-ui-pro-nux-nvtb

@DavidSabine
Copy link

Hi @RihanArfan,

There were 2 problems in my realm:

  1. The value of the secret was incorrect (erroneous whitespace)
  2. The yaml workflow file had tabs instead of spaces on line 31 (erroneous whitespace) - I will look to see why my IDE didn't lint and auto-correct that

All is working now.

Conversation with you was helpful. Much appreciated.

@valtlfelipe
Copy link

valtlfelipe commented Feb 20, 2025

Had the same issue. During setup on admin.hub.nuxt.com I did add the env variable, but still got the error. had to manually add the variable to the repository and edit the workflow file. Thanks @DavidSabine

I used nuxt hub before, and I didn't had this issue. Just now when it moved to use GH Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants