Fix CI/CD: Switch from Gitea Actions to Woodpecker CI workflow
- Disabled ci-cd-fast.yml (Gitea Actions syntax) - Added ci-cd-woodpecker.yml (proper Woodpecker CI syntax) - Fixed environment variable and secret access - Should resolve deployment issues with missing variables
This commit is contained in:
45
sync-env.ps1
45
sync-env.ps1
@@ -11,27 +11,43 @@ if (!(Get-Command bw -ErrorAction SilentlyContinue)) {
|
||||
}
|
||||
|
||||
# Check status
|
||||
$status = bw status | ConvertFrom-Json
|
||||
$statusOutput = bw status 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Error: Failed to get Bitwarden status" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
$status = $statusOutput | ConvertFrom-Json
|
||||
|
||||
if ($status.status -eq "unauthenticated") {
|
||||
Write-Host "Please login to Bitwarden:"
|
||||
bw login
|
||||
$status = bw status | ConvertFrom-Json
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Error: Failed to login to Bitwarden" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
$statusOutput = bw status 2>$null
|
||||
$status = $statusOutput | ConvertFrom-Json
|
||||
}
|
||||
|
||||
# Unlock if needed
|
||||
if ($status.status -eq "locked") {
|
||||
Write-Host "Unlocking vault..."
|
||||
$env:BW_SESSION = bw unlock --raw
|
||||
Write-Host "Please enter your Bitwarden master password:"
|
||||
$sessionKey = bw unlock --raw
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Error: Failed to unlock vault" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
$env:BW_SESSION = $sessionKey
|
||||
}
|
||||
|
||||
# Sync
|
||||
Write-Host "Syncing with Bitwarden..."
|
||||
bw sync | Out-Null
|
||||
bw sync 2>$null | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Error: Failed to sync with Bitwarden" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
# CHANGE THIS to your Bitwarden item name
|
||||
$itemName = "portfolio-env"
|
||||
@@ -39,24 +55,25 @@ $itemName = "portfolio-env"
|
||||
Write-Host "Fetching environment variables..."
|
||||
|
||||
# Get item
|
||||
$item = bw get item $itemName 2>$null | ConvertFrom-Json
|
||||
|
||||
if (!$item) {
|
||||
$itemOutput = bw get item $itemName 2>$null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Error: Could not find item '$itemName' in Bitwarden" -ForegroundColor Red
|
||||
Write-Host "Make sure you have an item with this exact name in your vault"
|
||||
exit 1
|
||||
}
|
||||
$item = $itemOutput | ConvertFrom-Json
|
||||
|
||||
# Get notes
|
||||
$notes = $item.notes
|
||||
|
||||
if (!$notes) {
|
||||
# Get notes and process them
|
||||
if (!$item.notes) {
|
||||
Write-Host "Error: No notes found in item '$itemName'" -ForegroundColor Red
|
||||
Write-Host "Add your environment variables to the notes field"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Create .env file
|
||||
$notes | Out-File -FilePath ".env" -Encoding UTF8 -NoNewline
|
||||
# Process notes - handle escaped newlines and other JSON formatting
|
||||
$notes = $item.notes -replace '\\n', "`n" -replace '\\r', "`r" -replace '\\t', "`t"
|
||||
|
||||
Write-Host "✓ Created .env file successfully!" -ForegroundColor Green
|
||||
# Create .env file
|
||||
$envPath = Join-Path (Get-Location) ".env"
|
||||
$notes | Out-File -FilePath $envPath -Encoding UTF8 -NoNewline
|
||||
Write-Host "Created .env file successfully at: $envPath" -ForegroundColor Green
|
||||
|
||||
Reference in New Issue
Block a user