Konfiguracja wdrazania Cloudflare Pages

This commit is contained in:
2026-09-18 19:21:23 +02:00
parent 5b9aba3df3
commit b90c3d137a
5 changed files with 84 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"account_id": "0a3818308d1764898fe0604506527911",
"project_name": "filtry"
}
+6
View File
@@ -0,0 +1,6 @@
{
"account": {
"id": "0a3818308d1764898fe0604506527911",
"name": "[email protected]'s Account"
}
}
+56
View File
@@ -0,0 +1,56 @@
param(
[string]$ProjectName,
[string]$AccountId
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$publishDirectory = Join-Path $root "wersja1"
$nodePath = "C:\Program Files\nodejs"
if ((Test-Path $nodePath) -and (($env:Path -split ";") -notcontains $nodePath)) {
$env:Path = "$nodePath;$env:Path"
}
if (-not (Test-Path (Join-Path $publishDirectory "index.html"))) {
throw "Folder wersja1 nie zawiera index.html."
}
if (-not $ProjectName) {
$ProjectName = $env:CLOUDFLARE_PAGES_PROJECT
}
if (-not $ProjectName) {
$ProjectName = git -C $root config --local --get cloudflare.pagesProject
}
if (-not $AccountId) {
$AccountId = $env:CLOUDFLARE_ACCOUNT_ID
}
if (-not $AccountId) {
$AccountId = git -C $root config --local --get cloudflare.accountId
}
if (-not $ProjectName) {
throw "Podaj nazwe projektu Pages przez -ProjectName albo CLOUDFLARE_PAGES_PROJECT."
}
$deployArguments = @("pages", "deploy", $publishDirectory, "--project-name", $ProjectName)
if ($AccountId) {
$deployArguments += @("--account-id", $AccountId)
}
$wrangler = $null
$wranglerCommand = Get-Command wrangler.cmd -ErrorAction SilentlyContinue
if ($wranglerCommand) {
$wrangler = $wranglerCommand.Source
} else {
$userWrangler = Join-Path $env:APPDATA "npm\wrangler.cmd"
if (Test-Path $userWrangler) {
$wrangler = $userWrangler
}
}
if ($wrangler) {
& $wrangler @deployArguments
} elseif (Get-Command npx.cmd -ErrorAction SilentlyContinue) {
npx.cmd --yes wrangler @deployArguments
} else {
throw "Nie znaleziono Wrangler ani npx. Zainstaluj Node.js LTS i uruchom ponownie terminal."
}
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
set -e
repo_root=$(git rev-parse --show-toplevel)
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "$repo_root/deploy-cloudflare.ps1"
+13
View File
@@ -0,0 +1,13 @@
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$hooks = Join-Path $root ".git\hooks"
$source = Join-Path $root "hooks\post-push"
$target = Join-Path $hooks "post-push"
if (-not (Test-Path $hooks)) {
throw "Nie znaleziono folderu .git/hooks. Uruchom skrypt w katalogu repozytorium."
}
Copy-Item $source $target -Force
Write-Host "Zainstalowano hook post-push: $target"
Write-Host "Po kazdym udanym git push zostanie uruchomiony deploy do Cloudflare Pages."