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

Is it possible to use nuxthub cli in GitHub Actions? #15

Closed
stonega opened this issue Jun 23, 2024 · 6 comments
Closed

Is it possible to use nuxthub cli in GitHub Actions? #15

stonega opened this issue Jun 23, 2024 · 6 comments
Labels
question Further information is requested

Comments

@stonega
Copy link

stonega commented Jun 23, 2024

If so, is there any documentation or examples available that demonstrate how to set it up?

@atinux
Copy link
Collaborator

atinux commented Jun 25, 2024

It is possible but not documented yet.

It should be the same as using any Node.js CI action + running npx nuxthub deploy with a 2 env variables:

  • NUXT_HUB_PROJECT_KEY that you can get in your project settings
  • NUXT_HUB_USER_TOKEN that you can create by cliking on your username in the admin -> Settings -> Tokens

CleanShot 2024-06-25 at 23 50 20@2x

Also released v0.5.13 of the CLI so it should work properly with the env variables.

Would love your feedback on this!

@atinux atinux added the question Further information is requested label Jun 25, 2024
@stonega
Copy link
Author

stonega commented Jun 26, 2024

Thanks, works like a charm

      - name: Nuxthub deploy
        run: npx nuxthub deploy
        env:
          NUXT_HUB_PROJECT_KEY: ${{ secrets.NUXT_HUB_PROJECT_KEY}}
          NUXT_HUB_USER_TOKEN: ${{ secrets.NUXT_HUB_USER_TOKEN }}

@stonega stonega closed this as completed Jun 26, 2024
Copy link
Collaborator

atinux commented Jun 27, 2024

Would you mind sharing your whole Github action so I could write it in the readme or in the docs?

Copy link
Collaborator

atinux commented Jun 27, 2024

(re-opening to keep it to do)

@atinux atinux reopened this Jun 27, 2024
@stonega
Copy link
Author

stonega commented Jun 27, 2024

@atinux It is pretty simple, just pnpm install && deploy.

name: Deploy to Cloudflare with NuxtHub Cli

on:
  push:
    branches: ['main']

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - uses: pnpm/action-setup@v4
        name: Install pnpm
        with:
          run_install: false

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

      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

      - uses: actions/cache@v4
        name: Setup pnpm cache
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-

      - name: Install dependencies
        run: pnpm install
      
      - name:  Deploy with nuxt-hub cli
        run: npx nuxthub deploy
        env:
          NUXT_HUB_PROJECT_KEY: ${{ secrets.NUXT_HUB_PROJECT_KEY}}
          NUXT_HUB_USER_TOKEN: ${{ secrets.NUXT_HUB_USER_TOKEN }}

Copy link
Collaborator

atinux commented Jun 28, 2024

Thanks for sharing!

Updated the docs https://hub.nuxt.com/docs/getting-started/deploy#github-action

@atinux atinux closed this as completed Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants