55 lines
1.4 KiB
YAML
55 lines
1.4 KiB
YAML
name: Deploy Portfolio
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: self-hosted
|
|
steps:
|
|
- name: Checkout code
|
|
run: |
|
|
rm -rf * .git
|
|
git clone "https://code.chagarlamudi.net/raghu-ch/rc-portfolio.git" .
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t rc-portfolio:latest .
|
|
|
|
- name: Stop old container
|
|
run: docker stop rc-portfolio || true
|
|
|
|
- name: Remove old container
|
|
run: docker rm rc-portfolio || true
|
|
|
|
- name: Run new container
|
|
run: |
|
|
docker run -d \
|
|
--name rc-portfolio \
|
|
--restart unless-stopped \
|
|
-p 8080:80 \
|
|
rc-portfolio:latest
|
|
|
|
- name: Clean up old images
|
|
run: docker image prune -f
|
|
|
|
# Email Notification (on success)
|
|
- name: Send success email
|
|
if: success()
|
|
uses: dawidd6/action-send-mail@v3
|
|
with:
|
|
server_address: smtp.gmail.com
|
|
server_port: 587
|
|
username: ${{ secrets.EMAIL_USERNAME }}
|
|
password: ${{ secrets.EMAIL_PASSWORD }}
|
|
subject: '✅ Deployment Successful - rc-portfolio'
|
|
to: raghu6004@gmail.com
|
|
from: GitHub Actions
|
|
body: |
|
|
Deployment completed successfully!
|
|
Repository: ${{ github.repository }}
|
|
Branch: ${{ github.ref }}
|
|
Commit: ${{ github.sha }}
|
|
Workflow: ${{ github.workflow }}
|