Skip to content

Commit f1e91f8

Browse files
committed
docs: add GitHub Action example
1 parent b2adb87 commit f1e91f8

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

docs/content/1.docs/1.getting-started/3.deploy.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,63 @@ The command will:
5252
::note
5353
You can also install the [NuxtHub CLI](https://github.com/nuxt-hub/cli) globally with: `npm i -g nuxthub`.
5454
::
55+
56+
#### GitHub Action
57+
58+
To deploy your project with a GitHub Action, you can use the following workflow:
59+
60+
```yaml [.github/workflows/deploy.yml]
61+
name: Deploy to Cloudflare with NuxtHub Cli
62+
on:
63+
push:
64+
branches: ['main']
65+
jobs:
66+
build-and-deploy:
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v4
71+
- uses: pnpm/action-setup@v4
72+
name: Install pnpm
73+
with:
74+
run_install: false
75+
- name: Install Node.js
76+
uses: actions/setup-node@v4
77+
with:
78+
node-version: 20
79+
cache: 'pnpm'
80+
- name: Get pnpm store directory
81+
shell: bash
82+
run: |
83+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
84+
- uses: actions/cache@v4
85+
name: Setup pnpm cache
86+
with:
87+
path: ${{ env.STORE_PATH }}
88+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
89+
restore-keys: |
90+
${{ runner.os }}-pnpm-store-
91+
- name: Install dependencies
92+
run: pnpm install
93+
- name: Deploy with nuxt-hub cli
94+
run: npx nuxthub deploy
95+
env:
96+
NUXT_HUB_PROJECT_KEY: ${{ secrets.NUXT_HUB_PROJECT_KEY}}
97+
NUXT_HUB_USER_TOKEN: ${{ secrets.NUXT_HUB_USER_TOKEN }}
98+
```
99+
100+
You need to add the following secrets to your GitHub repository:
101+
- `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`)
102+
- `NUXT_HUB_USER_TOKEN`: Your user token available in your profile settings → Tokens in the NuxtHub Admin
103+
104+
::tip
105+
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.
106+
::
107+
108+
::note
109+
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.
110+
::
111+
55112
## Self-hosted
56113

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

0 commit comments

Comments
 (0)