Skip to content

Commit ec8db07

Browse files
authored
tools: add ci label (#768)
1 parent 70c04f6 commit ec8db07

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

.github/workflows/auto-build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,5 @@ jobs:
4747
with:
4848
python-version: '3.9'
4949
architecture: 'x64'
50-
- name: Show Python version
51-
run: python -c "import sys; print(sys.version)"
5250
- name: Build and push
5351
run: tools/push -p linux/arm64

.github/workflows/manual-build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,5 @@ jobs:
5252
with:
5353
python-version: '3.9'
5454
architecture: 'x64'
55-
- name: Show Python version
56-
run: python -c "import sys; print(sys.version)"
5755
- name: Build and push
5856
run: tools/push -p linux/arm64 ${{ github.event.inputs.images }}

tools/core/image.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from .docker import ManifestList
1414
from .src import SourceManager
15-
from .utils import execute
15+
from .utils import execute, get_github_job_url
1616

1717
if TYPE_CHECKING:
1818
from .toolkit import Platform, Context
@@ -71,7 +71,7 @@ def get_shared_dir(self):
7171
def get_labels(self, application_revision) -> List[str]:
7272
image_revision = ""
7373
image_source = ""
74-
image_travis = ""
74+
image_ci = ""
7575

7676
if self.revision:
7777

@@ -81,15 +81,17 @@ def get_labels(self, application_revision) -> List[str]:
8181
source = "{}/blob/{}/images/{}/Dockerfile".format(self.context.project_repo, image_revision, self.name)
8282
image_source = source
8383

84-
if "TRAVIS_BUILD_WEB_URL" in os.environ:
85-
image_travis = os.environ["TRAVIS_BUILD_WEB_URL"]
84+
if "GITHUB_RUN_ID" in os.environ:
85+
run_id = os.environ["GITHUB_RUN_ID"]
86+
job_name = os.environ["GITHUB_JOB"]
87+
image_ci = get_github_job_url(run_id, job_name)
8688

8789
prefix = self.label_prefix
8890

8991
return [
9092
f"--label {prefix}.image.revision='{image_revision}'",
9193
f"--label {prefix}.image.source='{image_source}'",
92-
f"--label {prefix}.image.travis='{image_travis}'",
94+
f"--label {prefix}.image.ci='{image_ci}'",
9395
f"--label {prefix}.application.revision='{application_revision}'",
9496
# TODO remove labels below
9597
f"--label {prefix}.image.branch='master'",

tools/core/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
from subprocess import check_output, STDOUT
2+
from urllib.request import urlopen
3+
import json
4+
from typing import Optional
25

36

47
def execute(cmd: str) -> str:
58
output = check_output(cmd, shell=True, stderr=STDOUT)
69
return output.decode()
10+
11+
12+
def get_github_job_url(run_id: str, job_name: str) -> Optional[str]:
13+
url = "https://api.github.com/repos/ExchangeUnion/xud-docker/actions/runs/{}/jobs".format(run_id)
14+
resp = urlopen(url)
15+
j = json.load(resp)
16+
for job in j["jobs"]:
17+
if job["name"] == job_name:
18+
return "https://github.com/ExchangeUnion/xud-docker/runs/{}?check_suite_focus=true".format(job["id"])
19+
return None

0 commit comments

Comments
 (0)