mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-24 22:43:05 +00:00
workflows/gatekeeper: export COMMIT_HASH variable
The Github SHA of triggering PR should be exported in the environment so that gatekeeper can fetch the right workflows/jobs. Note: by default github will export GITHUB_SHA in the job's environment but that value cannot be used if the gatekeeper was triggered from a pull_request_target event, because the SHA correspond to the push branch. Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
This commit is contained in:
parent
4abfc11b4f
commit
fdcfac0641
1
.github/workflows/gatekeeper.yaml
vendored
1
.github/workflows/gatekeeper.yaml
vendored
@ -28,6 +28,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
|
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
|
||||||
run: |
|
run: |
|
||||||
#!/usr/bin/env bash -x
|
#!/usr/bin/env bash -x
|
||||||
mapfile -t lines < <(python3 tools/testing/gatekeeper/skips.py -t)
|
mapfile -t lines < <(python3 tools/testing/gatekeeper/skips.py -t)
|
||||||
|
@ -42,6 +42,7 @@ _GH_RUNS_URL = ("https://api.github.com/repos/"
|
|||||||
class Checker:
|
class Checker:
|
||||||
"""Object to keep watching required GH action workflows"""
|
"""Object to keep watching required GH action workflows"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.latest_commit_sha = os.getenv("COMMIT_HASH")
|
||||||
required_jobs = os.getenv("REQUIRED_JOBS")
|
required_jobs = os.getenv("REQUIRED_JOBS")
|
||||||
if required_jobs:
|
if required_jobs:
|
||||||
required_jobs = required_jobs.split(",")
|
required_jobs = required_jobs.split(",")
|
||||||
@ -151,10 +152,9 @@ class Checker:
|
|||||||
:returns: 0 - all passing; 1 - any failure; 127 some jobs running
|
:returns: 0 - all passing; 1 - any failure; 127 some jobs running
|
||||||
"""
|
"""
|
||||||
# TODO: Check if we need pagination here as well
|
# TODO: Check if we need pagination here as well
|
||||||
latest_commit_sha = os.getenv("COMMIT_HASH")
|
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
_GH_RUNS_URL,
|
_GH_RUNS_URL,
|
||||||
params={"head_sha": latest_commit_sha},
|
params={"head_sha": self.latest_commit_sha},
|
||||||
headers=_GH_HEADERS,
|
headers=_GH_HEADERS,
|
||||||
timeout=60
|
timeout=60
|
||||||
)
|
)
|
||||||
@ -174,6 +174,8 @@ class Checker:
|
|||||||
|
|
||||||
:returns: 0 on success; 1 on failure
|
:returns: 0 on success; 1 on failure
|
||||||
"""
|
"""
|
||||||
|
print(f"Gatekeeper for project={os.environ['GITHUB_REPOSITORY']} and "
|
||||||
|
f"SHA={self.latest_commit_sha}")
|
||||||
while True:
|
while True:
|
||||||
ret = self.check_workflow_runs_status()
|
ret = self.check_workflow_runs_status()
|
||||||
if ret == RUNNING:
|
if ret == RUNNING:
|
||||||
|
Loading…
Reference in New Issue
Block a user