mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-24 14:32:33 +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:
|
||||
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
COMMIT_HASH: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
#!/usr/bin/env bash -x
|
||||
mapfile -t lines < <(python3 tools/testing/gatekeeper/skips.py -t)
|
||||
|
@ -42,6 +42,7 @@ _GH_RUNS_URL = ("https://api.github.com/repos/"
|
||||
class Checker:
|
||||
"""Object to keep watching required GH action workflows"""
|
||||
def __init__(self):
|
||||
self.latest_commit_sha = os.getenv("COMMIT_HASH")
|
||||
required_jobs = os.getenv("REQUIRED_JOBS")
|
||||
if required_jobs:
|
||||
required_jobs = required_jobs.split(",")
|
||||
@ -151,10 +152,9 @@ class Checker:
|
||||
:returns: 0 - all passing; 1 - any failure; 127 some jobs running
|
||||
"""
|
||||
# TODO: Check if we need pagination here as well
|
||||
latest_commit_sha = os.getenv("COMMIT_HASH")
|
||||
response = requests.get(
|
||||
_GH_RUNS_URL,
|
||||
params={"head_sha": latest_commit_sha},
|
||||
params={"head_sha": self.latest_commit_sha},
|
||||
headers=_GH_HEADERS,
|
||||
timeout=60
|
||||
)
|
||||
@ -174,6 +174,8 @@ class Checker:
|
||||
|
||||
: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:
|
||||
ret = self.check_workflow_runs_status()
|
||||
if ret == RUNNING:
|
||||
|
Loading…
Reference in New Issue
Block a user