Skip to content

Commit

Permalink
docs: add GitHub Action example
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Jun 28, 2024
1 parent b2adb87 commit f1e91f8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions docs/content/1.docs/1.getting-started/3.deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,63 @@ The command will:
::note
You can also install the [NuxtHub CLI](https://github.com/nuxt-hub/cli) globally with: `npm i -g nuxthub`.
::

#### GitHub Action

To deploy your project with a GitHub Action, you can use the following workflow:

```yaml [.github/workflows/deploy.yml]
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 }}
```
You need to add the following secrets to your GitHub repository:
- `NUXT_HUB_PROJECT_KEY`: Your project key (available in your project settings in the NuxtHub Admin or in your `.env` file if you ran `nuxthub link`)
- `NUXT_HUB_USER_TOKEN`: Your user token available in your profile settings → Tokens in the NuxtHub Admin

::tip
We recommend to create a new user token for the Github CI so you can revoke it at any time or add an expiration date.
::

::note
This GitHub action uses pnpm to install dependencies. If you are using npm or yarn, we recommend you to adapt the action to your needs.
::

## Self-hosted

You can deploy your project on your own Cloudflare account without using the NuxtHub Admin.
Expand Down

0 comments on commit f1e91f8

Please sign in to comment.