@@ -15,6 +15,7 @@ permissions:
1515 contents : write
1616 pages : write
1717 id-token : write
18+ packages : write
1819
1920jobs :
2021 create-release :
@@ -175,141 +176,47 @@ jobs:
175176 asset_name : deploy.sh
176177 asset_content_type : application/x-shellscript
177178
178- - name : Generate Docker image (if Dockerfile exists)
179- if : hashFiles('Dockerfile') != ''
180- run : |
181- docker build -t seccodesmith/backend:${{ steps.version.outputs.version_number }} .
182- docker build -t seccodesmith/backend:latest .
183-
184- # Save Docker image as artifact
185- docker save seccodesmith/backend:${{ steps.version.outputs.version_number }} | gzip > dist/seccodesmith-backend-${{ steps.version.outputs.version_number }}-docker.tar.gz
186-
187- - name : Upload Docker Image
188- if : hashFiles('Dockerfile') != ''
189- uses : actions/upload-release-asset@v1
190- env :
191- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
192- with :
193- upload_url : ${{ steps.create_release.outputs.upload_url }}
194- asset_path : ./dist/seccodesmith-backend-${{ steps.version.outputs.version_number }}-docker.tar.gz
195- asset_name : seccodesmith-backend-${{ steps.version.outputs.version_number }}-docker.tar.gz
196- asset_content_type : application/gzip
197-
198- create-documentation :
179+ docker-release :
199180 runs-on : ubuntu-latest
200181 needs : create-release
201- if : github.ref == 'refs/heads/main ' || github.ref_type == 'tag '
182+ if : github.ref_type == 'tag ' || github.event_name == 'workflow_dispatch '
202183
203184 steps :
204185 - name : Checkout code
205186 uses : actions/checkout@v4
206187
207- - name : Set up Python
208- uses : actions/setup-python@v4
188+ - name : Set up Docker Buildx
189+ uses : docker/setup-buildx-action@v3
190+
191+ - name : Log in to GitHub Container Registry
192+ uses : docker/login-action@v3
209193 with :
210- python-version : 3.11.x
194+ registry : ghcr.io
195+ username : ${{ github.actor }}
196+ password : ${{ secrets.GITHUB_TOKEN }}
197+
198+ - name : Extract metadata
199+ id : meta
200+ uses : docker/metadata-action@v5
201+ with :
202+ images : |
203+ ghcr.io/${{ github.repository }}
204+ tags : |
205+ type=ref,event=tag
206+ type=raw,value=latest,enable={{is_default_branch}}
207+ type=semver,pattern={{version}}
208+ type=semver,pattern={{major}}.{{minor}}
209+
210+ - name : Build and push Docker image
211+ uses : docker/build-push-action@v5
212+ with :
213+ context : .
214+ platforms : linux/amd64,linux/arm64
215+ push : true
216+ tags : ${{ steps.meta.outputs.tags }}
217+ labels : ${{ steps.meta.outputs.labels }}
218+ cache-from : type=gha
219+ cache-to : type=gha,mode=max
211220
212- - name : Install documentation dependencies
213- run : |
214- python -m pip install --upgrade pip
215- pip install sphinx sphinx-rtd-theme
216221
217- - name : Generate API documentation
218- run : |
219- # Create basic documentation structure
220- mkdir -p docs/
221-
222- cat > docs/index.html << 'EOF'
223- <!DOCTYPE html>
224- <html lang="en">
225- <head>
226- <meta charset="UTF-8">
227- <meta name="viewport" content="width=device-width, initial-scale=1.0">
228- <title>SecCodeSmith Backend Documentation</title>
229- <style>
230- body { font-family: Arial, sans-serif; margin: 40px; line-height: 1.6; }
231- .header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 20px; border-radius: 8px; }
232- .section { margin: 20px 0; }
233- .code { background: #f4f4f4; padding: 10px; border-radius: 4px; font-family: monospace; }
234- .endpoint { background: #e8f5e8; padding: 10px; margin: 5px 0; border-left: 4px solid #4CAF50; }
235- </style>
236- </head>
237- <body>
238- <div class="header">
239- <h1>🔥 SecCodeSmith Backend API</h1>
240- <p>Django-powered REST API for the SecCodeSmith portfolio website</p>
241- </div>
242-
243- <div class="section">
244- <h2>📚 API Endpoints</h2>
245-
246- <div class="endpoint">
247- <strong>GET /api/csrf</strong><br>
248- Retrieve CSRF token for secure form submissions
249- </div>
250-
251- <div class="endpoint">
252- <strong>GET /api/skills-cards</strong><br>
253- List skill cards for frontend display
254- </div>
255-
256- <div class="endpoint">
257- <strong>GET /api/about/</strong><br>
258- Get content for the About page
259- </div>
260-
261- <div class="endpoint">
262- <strong>GET /api/footer-links</strong><br>
263- List social and footer links
264- </div>
265-
266- <div class="endpoint">
267- <strong>GET /api/contact/</strong><br>
268- Get content for the Contact page
269- </div>
270-
271- <div class="endpoint">
272- <strong>GET /blog-api/post/</strong><br>
273- List all blog posts
274- </div>
275-
276- <div class="endpoint">
277- <strong>GET /project-api/projects/</strong><br>
278- List all projects
279- </div>
280- </div>
281-
282- <div class="section">
283- <h2>🚀 Quick Start</h2>
284- <div class="code">
285- # Clone the repository<br>
286- git clone https://github.com/SecCodeSmith/SecCodeSmith-backend.git<br>
287- cd SecCodeSmith-backend<br><br>
288-
289- # Set up virtual environment<br>
290- python -m venv .venv<br>
291- source .venv/bin/activate # On Windows: .venv\Scripts\activate<br><br>
292-
293- # Install dependencies<br>
294- pip install -r requirements.txt<br><br>
295-
296- # Run migrations and start server<br>
297- python manage.py migrate<br>
298- python manage.py runserver
299- </div>
300- </div>
301-
302- <div class="section">
303- <h2>📖 More Information</h2>
304- <p>For detailed documentation, please refer to the <a href="https://github.com/SecCodeSmith/SecCodeSmith-backend">GitHub Repository</a>.</p>
305- </div>
306- </body>
307- </html>
308- EOF
309222
310- - name : Deploy to GitHub Pages
311- uses : peaceiris/actions-gh-pages@v3
312- with :
313- github_token : ${{ secrets.GITHUB_TOKEN }}
314- publish_dir : ./docs
315- destination_dir : docs
0 commit comments