Skip to content

Commit 58aa009

Browse files
committed
check env more thoroughly
1 parent 75c3ab3 commit 58aa009

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
run: python3 -m pip install requests
2424
- name: Optionally update README on Docker hub
2525
env:
26+
OPENGROK_REPO_SLUG: ${{ github.repository }}
2627
OPENGROK_PULL_REQUEST: ${{ github.head_ref }}
2728
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
2829
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

dev/dockerhub_readme.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,27 @@ def check_push_env():
7676

7777
logger = logging.getLogger(__name__)
7878

79-
if os.environ.get("OPENGROK_PULL_REQUEST"):
79+
repo_slug = os.environ.get("OPENGROK_REPO_SLUG")
80+
if repo_slug is None:
81+
logger.error("OPENGROK_REPO_SLUG environment variable not set")
82+
sys.exit(1)
83+
84+
if repo_slug != MAIN_REPO_SLUG:
85+
logger.info("Not updating Docker hub README for non main repo")
86+
sys.exit(0)
87+
88+
pull_request = os.environ.get("OPENGROK_PULL_REQUEST")
89+
if pull_request and len(pull_request) > 0:
8090
logger.info("Not updating Docker hub README for pull requests")
8191
sys.exit(0)
8292

8393
docker_username = os.environ.get("DOCKER_USERNAME")
84-
if docker_username is None:
94+
if docker_username is None or len(docker_username) == 0:
8595
logger.info("DOCKER_USERNAME is empty, exiting")
8696
sys.exit(1)
8797

8898
docker_password = os.environ.get("DOCKER_PASSWORD")
89-
if docker_password is None:
99+
if docker_password is None or len(docker_password) == 0:
90100
logger.info("DOCKER_PASSWORD is empty, exiting")
91101
sys.exit(1)
92102

0 commit comments

Comments
 (0)