mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-10 20:59:03 -04:00
Create Build-DockerContainer.ps1
Former-commit-id: 032028954b2ca85f55406133ccce423c4492e6a4 [formerly 7d83b45873a8ec01a4cd4d89034e596a6f9cce65 [formerly 5a87b6b92964ecf0ee82bf8dae873dba1153175e]] Former-commit-id: 70bc2b91db25bd69040eed4c5664d8ea08455153 Former-commit-id: 2618a0398ed042780c31f56eb88ba524184690e0
This commit is contained in:
parent
aa7390a765
commit
763f78c5bb
49
scripts/Build-DockerContainer.ps1
Normal file
49
scripts/Build-DockerContainer.ps1
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
param (
|
||||||
|
[string]$tag_name = "",
|
||||||
|
[switch]$dryrun = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
# DEV: To build the Docker container with a masnual dispatch (for testing only), provide an existing tag_name on master
|
||||||
|
|
||||||
|
# Provide parameters
|
||||||
|
$release_uri = 'https://api.github.com/repos/kiwix/kiwix-js-windows/actions/workflows/publish-docker.yaml/dispatches'
|
||||||
|
$github_token = Get-Content -Raw "$PSScriptRoot/github_token"
|
||||||
|
|
||||||
|
if ($tag_name -eq "") {
|
||||||
|
$tag_name = Read-Host "`nEnter the existing tag name to use for the manual docker build (e.g. 'v1.4.0')"
|
||||||
|
if (-Not $dryrun) {
|
||||||
|
$dryrun_check = Read-Host "Is this a dry run? [Y/N]"
|
||||||
|
$dryrun = -Not ( $dryrun_check -imatch 'n' )
|
||||||
|
If ($dryrun) {
|
||||||
|
"Initiating dry run..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($tag_name -NotMatch '^v\d+\.\d+\.\d+([EN-]|$)') {
|
||||||
|
"`nTag name must be in the format " + '"v0.0.0[E][N][-text]"!' + "`n"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set up dispatch_params object - for API see https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
|
||||||
|
$dispatch_params = @{
|
||||||
|
Uri = $release_uri
|
||||||
|
Method = 'POST'
|
||||||
|
Headers = @{
|
||||||
|
'Authorization' = "token $github_token"
|
||||||
|
'Accept' = 'application/vnd.github.v3+json'
|
||||||
|
}
|
||||||
|
Body = @{
|
||||||
|
'ref' = "master"
|
||||||
|
'inputs' = @{ 'version' = $tag_name }
|
||||||
|
} | ConvertTo-Json
|
||||||
|
ContentType = "application/json"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Post to the release server
|
||||||
|
if (-Not ($dryrun -or $buildonly -or $updatewinget)) {
|
||||||
|
$dispatch = Invoke-RestMethod @dispatch_params
|
||||||
|
} elseif (-Not $updatewinget) {
|
||||||
|
"[DRYRUN] Dispatch parameters:`n$dispatch_params`n$tag_name"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
"`nServer returned:`n$dispatch"
|
Loading…
x
Reference in New Issue
Block a user