Skip to content

Commit f93709d

Browse files
committed
add: workflow
1 parent dda2896 commit f93709d

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.github/workflows/nuxt.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
3+
# Sample workflow for building and deploying a Nuxt site to GitHub Pages
4+
#
5+
# To get started with Nuxt see: https://nuxtjs.org/docs/get-started/installation
6+
#
7+
name: Deploy Nuxt site to Pages
8+
9+
on:
10+
# Runs on pushes targeting the default branch
11+
push:
12+
branches: ["main"]
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
18+
permissions:
19+
contents: read
20+
pages: write
21+
id-token: write
22+
23+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
24+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
25+
concurrency:
26+
group: "pages"
27+
cancel-in-progress: false
28+
29+
jobs:
30+
# Build job
31+
build:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
- name: Detect package manager
37+
id: detect-package-manager
38+
run: |
39+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
40+
echo "manager=yarn" >> $GITHUB_OUTPUT
41+
echo "command=install" >> $GITHUB_OUTPUT
42+
exit 0
43+
elif [ -f "${{ github.workspace }}/package.json" ]; then
44+
echo "manager=npm" >> $GITHUB_OUTPUT
45+
echo "command=ci" >> $GITHUB_OUTPUT
46+
exit 0
47+
else
48+
echo "Unable to determine package manager"
49+
exit 1
50+
fi
51+
- name: Setup Node
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: "20"
55+
cache: ${{ steps.detect-package-manager.outputs.manager }}
56+
- name: Restore cache
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
dist
61+
.nuxt
62+
key: ${{ runner.os }}-nuxt-build-${{ hashFiles('dist') }}
63+
restore-keys: |
64+
${{ runner.os }}-nuxt-build-
65+
- name: Install dependencies
66+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
67+
- name: Static HTML export with Nuxt
68+
run: ${{ steps.detect-package-manager.outputs.manager }} run generate
69+
- name: Upload artifact
70+
uses: actions/upload-pages-artifact@v3
71+
with:
72+
path: ./dist
73+
74+
# Deployment job
75+
deploy:
76+
environment:
77+
name: github-pages
78+
url: ${{ steps.deployment.outputs.page_url }}
79+
runs-on: ubuntu-latest
80+
needs: build
81+
steps:
82+
- name: Deploy to GitHub Pages
83+
id: deployment
84+
uses: actions/deploy-pages@v4

nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default defineNuxtConfig({
3333
],
3434
},
3535
app: {
36+
baseURL: import.meta.env.NODE_ENV === 'development' ? '/' : '/tokei/',
3637
head: {
3738
htmlAttrs: {
3839
class: 'dark',

0 commit comments

Comments
 (0)