-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (102 loc) · 3.15 KB
/
deploy.yml
File metadata and controls
116 lines (102 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Deploy to GitHub Pages
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, canceling previous deployments to prevent queue buildup
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Build job
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Configure npm for better reliability
run: |
npm config set fetch-retries 10
npm config set fetch-retry-mintimeout 30000
npm config set fetch-retry-maxtimeout 300000
npm config set fetch-timeout 600000
npm config set registry https://registry.npmjs.org/
npm config set maxsockets 1
npm config set prefer-offline true
- name: Clear npm cache
run: npm cache clean --force
- name: Install dependencies with retry and fallback
run: |
echo "Removing potentially corrupted package-lock.json"
rm -f package-lock.json
for i in {1..5}; do
echo "Attempt $i of 5..."
if npm install --legacy-peer-deps --no-audit --no-fund --verbose; then
echo "Dependencies installed successfully!"
break
else
echo "Attempt $i failed"
if [ $i -lt 5 ]; then
echo "Waiting 60 seconds before retry..."
sleep 60
echo "Clearing npm cache..."
npm cache clean --force
else
echo "All attempts failed."
exit 1
fi
fi
done
- name: Build project
run: npm run build:production
env:
NODE_ENV: production
CI: true
- name: Add .nojekyll file and verify build output
run: |
mkdir -p out
touch out/.nojekyll
echo "Build output structure:"
ls -la out/
echo "Verifying index.html exists:"
ls -la out/index.html || echo "index.html not found"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./out
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
with:
timeout: 300000 # 5 minutos em vez do padrão de 10 minutos
error_count: 5 # Reduzido de 10 para 5 tentativas
reporting_interval: 10000 # Relatório a cada 10 segundos