This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Baphomet Server Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
- name: Set Environment Variables | |
shell: powershell | |
run: Start-Process -FilePath "powershell.exe" -ArgumentList "-Command ./set-env-variables.ps1" -Verb RunAs | |
- name: Install Docker Compose (if needed) | |
shell: powershell | |
run: | | |
if (-not (Get-Command docker-compose -ErrorAction SilentlyContinue)) { | |
$installPath = "${{ runner.temp }}/docker-compose.exe" | |
Invoke-WebRequest -Uri "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Windows-x86_64.exe" -OutFile $installPath | |
Start-Process -FilePath "powershell.exe" -ArgumentList "-Command | |
Move-Item -Path $installPath -Destination 'C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe'" -Verb RunAs | |
Write-Output "Docker Compose Installed" | |
} else { | |
Write-Output "Docker Compose already installed" | |
} | |
- name: Docker Login | |
run: | | |
echo "-u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}" --password-stdin | |
- name: Verify Docker Hub Login | |
shell: powershell | |
run: Start-Process -FilePath "powershell.exe" -ArgumentList "-Command ./verify-docker-login.ps1" -Verb RunAs | |
- name: Build Docker Images with Elevated Privileges | |
shell: powershell | |
run: Start-Process -FilePath "powershell.exe" -ArgumentList "-Command ./build-docker-image.ps1" | |
- name: Tag Docker Image with Elevated Privileges | |
shell: powershell | |
run: | | |
Start-Process -FilePath "docker" -ArgumentList "tag baphomet-server:latest collinlucke/baphomet-server:latest" -Verb RunAs | |
- name: Push Docker Images with Elevated Privileges | |
shell: powershell | |
run: Start-Process -FilePath "powershell.exe" -ArgumentList "-Command docker-compose -f docker-compose.yml push" -Verb RunAs | |
deploy: | |
needs: build | |
runs-on: self-hosted | |
steps: | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
- name: Install Docker Compose (if needed) | |
shell: powershell | |
run: | | |
if (-not (Get-Command docker-compose -ErrorAction SilentlyContinue)) { | |
$installPath = "${{ runner.temp }}/docker-compose.exe" | |
Invoke-WebRequest -Uri "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Windows-x86_64.exe" -OutFile $installPath | |
Start-Process -FilePath "powershell.exe" -ArgumentList "-Command | |
Move-Item -Path $installPath -Destination 'C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe'" -Verb RunAs | |
Write-Output "Docker Compose Installed" | |
} else { | |
Write-Output "Docker Compose already installed" | |
} | |
- name: Pull Image from Docker Hub | |
run: docker-compose -f docker-compose.yml pull | |
- name: Delete Old Container | |
run: docker rm -f baphomet-server-container | |
- name: Run Docker Container | |
run: docker-compose -f docker-compose.yml up -d |