Konfiguracja wdrazania Cloudflare Pages
This commit is contained in:
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"account_id": "0a3818308d1764898fe0604506527911",
|
||||||
|
"project_name": "filtry"
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"account": {
|
||||||
|
"id": "0a3818308d1764898fe0604506527911",
|
||||||
|
"name": "[email protected]'s Account"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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."
|
||||||
|
}
|
||||||
@@ -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"
|
||||||
@@ -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."
|
||||||
Reference in New Issue
Block a user