Skip to content

Commit

Permalink
fix github pages workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wicksipedia committed Jan 20, 2025
1 parent 7d3ed3a commit e4c888e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
38 changes: 28 additions & 10 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name: Deploy Next.js site to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: [$default-branch]
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -31,46 +31,57 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "✅ Detected yarn"
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "✅ Detected pnpm"
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=pnpm" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "✅ Detected npm"
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: "${{ github.workspace }}/.nvmrc"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v4
with:
version: 9
- name: Setup Pages

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: ${{ steps.detect-package-manager.outputs.manager }}

- name: "Setup Pages #1"
run: |
touch public/.nojekyll
- name: "Setup Pages #2"
uses: actions/configure-pages@v5
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next

- name: Restore cache
uses: actions/cache@v4
with:
Expand All @@ -81,10 +92,17 @@ jobs:
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/pnpm-lock.yaml', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}

- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
run: ${{ steps.detect-package-manager.outputs.runner }} build
env:
NEXT_PUBLIC_TINA_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_TINA_CLIENT_ID }}
NEXT_PUBLIC_TINA_BRANCH: ${{ github.ref_name }}
TINA_TOKEN: ${{ secrets.TINA_TOKEN }}

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand All @@ -100,4 +118,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
10 changes: 10 additions & 0 deletions app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Page from './[...filename]/page';

export const Index = async ({ params }) => {
return Page({
...params,
params: { filename: ['home'] },
});
}

export default Index;

0 comments on commit e4c888e

Please sign in to comment.