-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makefile / GH Workflow: handle multi arch images
- Loading branch information
1 parent
d759477
commit b4b4472
Showing
4 changed files
with
184 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
GitHub Workflow Commands (gwc) for GitHub Actions can help us pass information | ||
from a Workflow's Job's various build steps to others via "output" and improve | ||
the presented logs when viewed via the GitHub web based UI. | ||
Reference: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions | ||
Workflow commands relies on emitting messages: | ||
print("::{command name} parameter1={data},parameter2={data}::{command value}") | ||
The functions defined in this file will only emit such messages if found to be | ||
in a GitHub CI environment. | ||
""" | ||
|
||
import json | ||
import os | ||
|
||
from contextlib import contextmanager | ||
|
||
|
||
def _gwc(command_name, command_value="", **params): | ||
if not os.environ.get("GITHUB_ACTIONS"): | ||
return | ||
|
||
# Assume non-string values are meant to be dumped as JSON | ||
if not isinstance(command_value, str): | ||
command_value = json.dumps(command_value) | ||
print(f"dumped json: {command_value}") | ||
|
||
if params: | ||
comma_sep_params = ",".join([f"{k}={v}" for k, v in params.items()]) | ||
print(f"::{command_name} {comma_sep_params}::{command_value}") | ||
else: | ||
print(f"::{command_name}::{command_value}") | ||
|
||
|
||
@contextmanager | ||
def _gwc_group(group_name): | ||
""" | ||
Entering the context prints the group command, and exiting the context | ||
prints the endgroup command.<< | ||
""" | ||
try: | ||
yield _gwc("group", group_name) | ||
finally: | ||
_gwc("endgroup", group_name) | ||
|
||
|
||
def _gwc_set_env(env_name, env_value): | ||
if not os.environ.get("GITHUB_ACTIONS") or not os.environ.get("GITHUB_ENV"): | ||
return | ||
|
||
with open(os.environ["GITHUB_ENV"], "a") as f: | ||
f.write(f"{env_name}={env_value}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters