Skip to content

Commit 5777ade

Browse files
committed
[actions] add deploy action
1 parent a64218a commit 5777ade

2 files changed

Lines changed: 178 additions & 0 deletions

File tree

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: Deploy to Yandex Object Storage (s5cmd)
2+
3+
on:
4+
push:
5+
branches: [master, main]
6+
pull_request:
7+
branches: [master, main]
8+
workflow_dispatch:
9+
10+
env:
11+
PYTHON_VERSION: "3.11"
12+
13+
jobs:
14+
build-and-deploy:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python version
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ env.PYTHON_VERSION }}
25+
26+
- name: Cache pip dependencies
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -r requirements.txt
38+
39+
- name: Build MkDocs site
40+
run: |
41+
mkdocs build --strict
42+
43+
- name: Verify build output
44+
run: |
45+
ls -la site/
46+
echo "Build completed successfully"
47+
echo "Site size: $(du -sh site/ | cut -f1)"
48+
49+
- name: Install s5cmd
50+
run: |
51+
# Download and install s5cmd
52+
wget https://github.com/peak/s5cmd/releases/download/v2.3.0/s5cmd_2.3.0_Linux_amd.tar.gz
53+
tar -xzf s5cmd_2.3.0_Linux_amd.tar.gz
54+
chmod +x s5cmd
55+
sudo mv s5cmd /usr/local/bin/
56+
57+
# Verify installation
58+
s5cmd version
59+
60+
- name: Configure s5cmd credentials
61+
run: |
62+
# Create AWS credentials file for s5cmd
63+
mkdir -p ~/.aws
64+
cat > ~/.aws/credentials << EOF
65+
[default]
66+
aws_access_key_id = ${{ secrets.YANDEX_STORAGE_ACCESS_KEY }}
67+
aws_secret_access_key = ${{ secrets.YANDEX_STORAGE_SECRET_KEY }}
68+
EOF
69+
70+
# Create AWS config file
71+
cat > ~/.aws/config << EOF
72+
[default]
73+
region = us-east-1
74+
s3 =
75+
endpoint_url = ${{ secrets.YANDEX_STORAGE_ENDPOINT }}
76+
EOF
77+
78+
- name: Deploy to Yandex Object Storage with s5cmd
79+
run: |
80+
echo "🚀 Starting deployment with s5cmd..."
81+
82+
# Sync files to Object Storage with s5cmd
83+
# Using high-performance parallel uploads
84+
s5cmd sync site/ s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/ \
85+
--delete \
86+
--exclude "*.git*" \
87+
--exclude ".*" \
88+
--size-only \
89+
--concurrency 10
90+
91+
echo "✅ Files synced successfully"
92+
93+
- name: Set proper content types with s5cmd
94+
run: |
95+
echo "📝 Setting content types..."
96+
97+
# Set content type for HTML files
98+
s5cmd set --content-type "text/html" \
99+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.html"
100+
101+
# Set content type for CSS files
102+
s5cmd set --content-type "text/css" \
103+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.css"
104+
105+
# Set content type for JavaScript files
106+
s5cmd set --content-type "application/javascript" \
107+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.js"
108+
109+
# Set content type for JSON files
110+
s5cmd set --content-type "application/json" \
111+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.json"
112+
113+
# Set content type for XML files
114+
s5cmd set --content-type "application/xml" \
115+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.xml"
116+
117+
# Set content type for common image formats
118+
s5cmd set --content-type "image/png" \
119+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.png"
120+
121+
s5cmd set --content-type "image/jpeg" \
122+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.jpg"
123+
124+
s5cmd set --content-type "image/jpeg" \
125+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.jpeg"
126+
127+
s5cmd set --content-type "image/svg+xml" \
128+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.svg"
129+
130+
# Set content type for fonts
131+
s5cmd set --content-type "font/woff2" \
132+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.woff2"
133+
134+
s5cmd set --content-type "font/woff" \
135+
"s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/*.woff"
136+
137+
echo "✅ Content types set successfully"
138+
139+
- name: Verify deployment
140+
run: |
141+
echo "🔍 Verifying deployment..."
142+
143+
# List files in the bucket
144+
echo "Files in bucket:"
145+
s5cmd ls s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/ | head -20
146+
147+
# Check if index.html exists
148+
s5cmd stat s3://${{ secrets.YANDEX_STORAGE_BUCKET }}/index.html
149+
150+
echo "✅ Deployment verification completed"
151+
152+
- name: Performance statistics
153+
run: |
154+
echo "📊 Deployment statistics:"
155+
echo "Site built at: $(date)"
156+
echo "Total files: $(find site/ -type f | wc -l)"
157+
echo "Total size: $(du -sh site/ | cut -f1)"
158+
echo "Bucket: ${{ secrets.YANDEX_STORAGE_BUCKET }}"
159+
echo "Endpoint: ${{ secrets.YANDEX_STORAGE_ENDPOINT }}"
160+
161+
# Calculate deployment time
162+
echo "Deployment completed in: $((SECONDS / 60)) minutes and $((SECONDS % 60)) seconds"
163+
164+
- name: Deployment summary
165+
run: |
166+
echo "🎉 Deployment completed successfully!"
167+
echo "📁 Site deployed to: ${{ secrets.YANDEX_STORAGE_ENDPOINT }}/${{ secrets.YANDEX_STORAGE_BUCKET }}"
168+
echo "🌐 Site URL: https://${{ secrets.YANDEX_STORAGE_BUCKET }}.${{ secrets.YANDEX_STORAGE_ENDPOINT }}"
169+
echo "⚡ Deployed with s5cmd for maximum performance"
170+
171+
- name: Cleanup credentials
172+
if: always()
173+
run: |
174+
# Remove AWS credentials
175+
rm -rf ~/.aws
176+
echo "🧹 Credentials cleaned up"

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mkdocs==1.5.3
2+
mkdocs-material==9.5.3

0 commit comments

Comments
 (0)