This commit is contained in:
65
.github/workflows/deploy.yml
vendored
65
.github/workflows/deploy.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone or Update Repository
|
- name: Deploy Application
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
uses: appleboy/ssh-action@v1.0.3
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.REMOTE_HOST }}
|
host: ${{ secrets.REMOTE_HOST }}
|
||||||
@@ -16,44 +16,31 @@ jobs:
|
|||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
||||||
script: |
|
script: |
|
||||||
powershell -Command "if (Test-Path 'C:\projects\digital-resume-FE') { Set-Location C:\projects\digital-resume-FE; git pull origin main } else { New-Item -ItemType Directory -Path C:\projects -Force; Set-Location C:\projects; git clone https://gitea.sashabayda.ca/Bayda77/digital-resume-FE.git; Set-Location digital-resume-FE }"
|
powershell -Command "
|
||||||
|
# Clone or update repository
|
||||||
|
if (Test-Path 'C:\projects\digital-resume-FE') {
|
||||||
|
Set-Location C:\projects\digital-resume-FE
|
||||||
|
git pull origin main
|
||||||
|
} else {
|
||||||
|
New-Item -ItemType Directory -Path C:\projects -Force
|
||||||
|
Set-Location C:\projects
|
||||||
|
git clone https://gitea.sashabayda.ca/Bayda77/digital-resume-FE.git
|
||||||
|
Set-Location digital-resume-FE
|
||||||
|
}
|
||||||
|
|
||||||
- name: Stop and Remove Existing Container
|
# Stop and remove existing container
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
`$container = docker ps -a -q -f name=resume-frontend
|
||||||
with:
|
if (`$container) {
|
||||||
host: ${{ secrets.REMOTE_HOST }}
|
docker stop resume-frontend
|
||||||
username: ${{ secrets.REMOTE_USER }}
|
Start-Sleep -Seconds 2
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
docker rm resume-frontend
|
||||||
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
}
|
||||||
script: |
|
|
||||||
powershell -Command "$container = docker ps -a -q -f name=resume-frontend; if ($container) { docker stop resume-frontend; Start-Sleep -Seconds 2; docker rm resume-frontend }"
|
|
||||||
|
|
||||||
- name: Build Docker Image
|
# Build and run new container
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
Set-Location C:\projects\digital-resume-FE
|
||||||
with:
|
docker build -t resume-frontend:latest .
|
||||||
host: ${{ secrets.REMOTE_HOST }}
|
docker run -d --name resume-frontend --restart unless-stopped -p 3000:80 resume-frontend:latest
|
||||||
username: ${{ secrets.REMOTE_USER }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
|
||||||
script: |
|
|
||||||
powershell -Command "Set-Location C:\projects\digital-resume-FE; docker build -t resume-frontend:latest ."
|
|
||||||
|
|
||||||
- name: Run Docker Container
|
# Cleanup unused images
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
docker image prune -f
|
||||||
with:
|
"
|
||||||
host: ${{ secrets.REMOTE_HOST }}
|
|
||||||
username: ${{ secrets.REMOTE_USER }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
|
||||||
script: |
|
|
||||||
powershell -Command "docker run -d --name resume-frontend --restart unless-stopped -p 3000:80 resume-frontend:latest"
|
|
||||||
|
|
||||||
- name: Cleanup Unused Images
|
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.REMOTE_HOST }}
|
|
||||||
username: ${{ secrets.REMOTE_USER }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
passphrase: ${{ secrets.SSH_PASSPHRASE }}
|
|
||||||
script: |
|
|
||||||
powershell -Command "docker image prune -f"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user