The Detenator
The Detenator2w ago

Deploying convex and astro on github pages with github action

I am looking at the Custom Domains & Hosting and it explains how to manually deploy to github pages. I am currently deploying to gh pages using a github action, I am using the withastro/action@v3 action to do the deployment. So I am unsure on how to do the step that says to run npx convex deploy --cmd 'npm run build' I am never runing npm run in the gh action. how am I supposed to do this? is it even possible to do an automatic deployment? do I have to put in the env vars manually in github secrets after running convex deploy locally?
3 Replies
Convex Bot
Convex Bot2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart2w ago
That doc mentions that you would follow the Vite GitHub Pages guide. In that guide, npm run build is run by the action: https://vite.dev/guide/static-deploy.html#github-pages You would swap npm run build for npx convex deploy --cmd 'npm run build'
The Detenator
The DetenatorOP2w ago
ya, I ended up rewriting my action to not use the astro provided build action this is what I have that works
name: Deploy to GitHub Pages

on:
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4
with:
lfs: true

- name: Checkout LFS objects
run: git lfs checkout

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Deploy Convex and build site
run: bunx convex deploy --cmd 'bun run build'
env:
CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}

- name: Setup Pages
id: pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
name: Deploy to GitHub Pages

on:
push:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4
with:
lfs: true

- name: Checkout LFS objects
run: git lfs checkout

- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Deploy Convex and build site
run: bunx convex deploy --cmd 'bun run build'
env:
CONVEX_DEPLOY_KEY: ${{ secrets.CONVEX_DEPLOY_KEY }}

- name: Setup Pages
id: pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

Did you find this page helpful?