Skip to content

Commit be18a5a

Browse files
committed
Add GitHub Actions workflow for automatic deployment to GitHub Pages. Update README.md with deployment instructions and enhance Vite configuration to include .nojekyll file. Modify CNAME for correct domain.
1 parent 529c790 commit be18a5a

File tree

5 files changed

+133
-5
lines changed

5 files changed

+133
-5
lines changed

.github/workflows/deploy.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "20"
29+
cache: "npm"
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
34+
- name: Build
35+
run: npm run build
36+
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v4
39+
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: "./dist"
44+
45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
runs-on: ubuntu-latest
50+
needs: build
51+
steps:
52+
- name: Deploy to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

.nojekyll

Whitespace-only changes.

CNAME

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
www.duckdevlabs.com
1+
duckdevlabs.com

README.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,66 @@ duckdevlabs.github.io/
5757
- Vite 5
5858
- CSS Vanilla (sem frameworks CSS)
5959

60-
## 📝 Deploy
60+
## 📝 Deploy no GitHub Pages
6161

62-
O site está configurado para GitHub Pages. Após o build, os arquivos serão gerados na pasta `dist/`.
62+
### Configuração Automática (Recomendado)
6363

64-
O arquivo `CNAME` já está configurado para `duckdevlabs.com`.
64+
O projeto já está configurado com GitHub Actions para deploy automático. Basta:
65+
66+
1. **Habilitar GitHub Pages no repositório:**
67+
- Vá em Settings → Pages
68+
- Em "Source", selecione **"GitHub Actions"**
69+
- Salve as configurações
70+
71+
2. **Fazer push das mudanças:**
72+
73+
```bash
74+
git add .
75+
git commit -m "Configura deploy automático"
76+
git push origin main
77+
```
78+
79+
3. O GitHub Actions vai automaticamente:
80+
- Fazer build do projeto
81+
- Fazer deploy para GitHub Pages
82+
- Atualizar o site sempre que você fizer push na branch `main`
83+
84+
### Deploy Manual (Alternativo)
85+
86+
Se preferir fazer deploy manual:
87+
88+
```bash
89+
# 1. Build do projeto
90+
npm run build
91+
92+
# 2. Fazer push da pasta dist/ para a branch gh-pages
93+
# (ou configurar para usar a branch main como source)
94+
```
95+
96+
### Configurações Importantes
97+
98+
-**CNAME**: Já configurado para `duckdevlabs.com`
99+
-**.nojekyll**: Criado automaticamente no build para GitHub Pages processar corretamente
100+
-**GitHub Actions**: Workflow configurado em `.github/workflows/deploy.yml`
101+
-**HTTPS**: Todas as URLs estão configuradas com HTTPS
102+
103+
### Verificar o Deploy
104+
105+
Após o deploy, você pode verificar:
106+
107+
- Actions tab no GitHub: Veja se o workflow foi executado com sucesso
108+
- Settings → Pages: Veja o status do deploy
109+
- Acesse `https://duckdevlabs.com` para ver o site no ar
110+
111+
### Problemas Comuns
112+
113+
**Site aparece em branco:**
114+
115+
- Verifique se o GitHub Pages está usando **"GitHub Actions"** como source (não "Deploy from a branch")
116+
- Verifique os logs na aba Actions para erros
117+
- Confirme que o arquivo `.nojekyll` está na pasta `dist/`
118+
119+
**Assets não carregam:**
120+
121+
- Certifique-se de que o build foi feito corretamente (`npm run build`)
122+
- Verifique se os arquivos estão na pasta `dist/assets/`

vite.config.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
import { defineConfig } from 'vite'
22
import react from '@vitejs/plugin-react'
3+
import { copyFileSync, existsSync } from 'fs'
4+
import { join } from 'path'
35

46
export default defineConfig({
5-
plugins: [react()],
7+
plugins: [
8+
react(),
9+
{
10+
name: 'copy-nojekyll',
11+
closeBundle() {
12+
const nojekyllSrc = join(process.cwd(), '.nojekyll')
13+
const nojekyllDest = join(process.cwd(), 'dist', '.nojekyll')
14+
if (existsSync(nojekyllSrc)) {
15+
copyFileSync(nojekyllSrc, nojekyllDest)
16+
}
17+
},
18+
},
19+
],
620
base: '/',
721
build: {
822
assetsDir: 'assets',
23+
outDir: 'dist',
24+
emptyOutDir: true,
925
rollupOptions: {
1026
output: {
1127
assetFileNames: 'assets/[name].[hash].[ext]',

0 commit comments

Comments
 (0)