Fixed #465: trigger docker publish on release
This triggers a `workflow_dispatch` event on the `docker.yml` workflow or the matching repository for both `zim-tools` and `kiwix-tools` targets that supports it.
This commit is contained in:
parent
9597662be8
commit
ff66a96980
|
@ -14,6 +14,7 @@ from common import (
|
||||||
update_flathub_git,
|
update_flathub_git,
|
||||||
upload_archive,
|
upload_archive,
|
||||||
fix_macos_rpath,
|
fix_macos_rpath,
|
||||||
|
trigger_docker_publish,
|
||||||
BASE_DIR,
|
BASE_DIR,
|
||||||
TMP_DIR,
|
TMP_DIR,
|
||||||
HOME,
|
HOME,
|
||||||
|
@ -75,6 +76,8 @@ for target in TARGETS:
|
||||||
archive = make_archive(target, make_release=RELEASE)
|
archive = make_archive(target, make_release=RELEASE)
|
||||||
if archive:
|
if archive:
|
||||||
upload_archive(archive, target, make_release=RELEASE)
|
upload_archive(archive, target, make_release=RELEASE)
|
||||||
|
if RELEASE and target in ("zim-tools", "kiwix-tools"):
|
||||||
|
trigger_docker_publish(target)
|
||||||
|
|
||||||
# We have few more things to do for release:
|
# We have few more things to do for release:
|
||||||
if RELEASE:
|
if RELEASE:
|
||||||
|
|
|
@ -8,6 +8,8 @@ import subprocess
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
from kiwixbuild.versions import (
|
from kiwixbuild.versions import (
|
||||||
main_project_versions,
|
main_project_versions,
|
||||||
release_versions,
|
release_versions,
|
||||||
|
@ -391,3 +393,47 @@ def fix_macos_rpath(project):
|
||||||
command = ["install_name_tool", "-id", lib.name, str(lib)]
|
command = ["install_name_tool", "-id", lib.name, str(lib)]
|
||||||
print_message("call {}", " ".join(command))
|
print_message("call {}", " ".join(command))
|
||||||
subprocess.check_call(command, env=os.environ)
|
subprocess.check_call(command, env=os.environ)
|
||||||
|
|
||||||
|
|
||||||
|
def trigger_workflow(repo, workflow="docker.yml", ref="master", inputs=None):
|
||||||
|
"""triggers a `workflow_dispatch` event to the specified workflow on its repo
|
||||||
|
|
||||||
|
repo: {user}/{repo} format
|
||||||
|
workflow: workflow ID or workflow file name
|
||||||
|
ref: branch or tag name
|
||||||
|
inputs: dict of inputs to pass to the workflow"""
|
||||||
|
print_message(
|
||||||
|
"triggering workflow `{workflow}` on {repo}@{ref} "
|
||||||
|
"with inputs={inputs}", workflow=workflow, repo=repo, ref=ref, inputs=inputs)
|
||||||
|
|
||||||
|
url = "{base_url}/repos/{repo}/actions/workflows/{workflow}/dispatches".format(
|
||||||
|
base_url=os.getenv("GITHUB_API_URL", "https://api.github.com"),
|
||||||
|
repo=repo, workflow=workflow)
|
||||||
|
|
||||||
|
resp = requests.post(url, headers={
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "token {token}".format(
|
||||||
|
token=os.getenv('GITHUB_PAT', '')),
|
||||||
|
"Accept": "application/vnd.github.v3+json",
|
||||||
|
}, json={"ref": ref, "inputs": inputs}, timeout=5)
|
||||||
|
if resp.status_code != 204:
|
||||||
|
raise ValueError("Unexpected HTTP {code}: {reason}".format(
|
||||||
|
code=resp.status_code, reason=resp.reason))
|
||||||
|
|
||||||
|
|
||||||
|
def trigger_docker_publish(target):
|
||||||
|
if target not in ("zim-tools", "kiwix-tools"):
|
||||||
|
return
|
||||||
|
|
||||||
|
version = get_postfix(target)
|
||||||
|
repo = {
|
||||||
|
"zim-tools": "openzim/zim-tools",
|
||||||
|
"kiwix-tools": "kiwix/kiwix-tools"}.get(target)
|
||||||
|
|
||||||
|
try:
|
||||||
|
trigger_workflow(repo, workflow="docker.yml", ref="master",
|
||||||
|
inputs={"version": version})
|
||||||
|
print_message("triggered docker workflow on {repo}", repo=repo)
|
||||||
|
except Exception as exc:
|
||||||
|
print_message("Error triggering workflow: {exc}", exc=exc)
|
||||||
|
raise exc
|
||||||
|
|
|
@ -113,6 +113,7 @@ jobs:
|
||||||
PLATFORM_TARGET: ${{matrix.target}}
|
PLATFORM_TARGET: ${{matrix.target}}
|
||||||
BINTRAY_USER: kiwix
|
BINTRAY_USER: kiwix
|
||||||
BINTRAY_PASS: ${{secrets.bintray_pass}}
|
BINTRAY_PASS: ${{secrets.bintray_pass}}
|
||||||
|
GITHUB_PAT: ${{secrets.GHCR_TOKEN}}
|
||||||
- name: Upload failure logs
|
- name: Upload failure logs
|
||||||
if: failure()
|
if: failure()
|
||||||
run: $HOME/kiwix-build/.github/scripts/upload_failure_logs.sh
|
run: $HOME/kiwix-build/.github/scripts/upload_failure_logs.sh
|
||||||
|
|
Loading…
Reference in New Issue