-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes current branch check problem when tag is pushed to push docker tags #184
Conversation
@@ -299,10 +300,29 @@ def prepend_line_in_file(file: str, match_regex: str, append_str: str) -> bool: | |||
|
|||
return has_match | |||
|
|||
def is_tag_on_branch(tag_name: str, branch_name: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new method to check whether branch contains tag
@@ -147,8 +147,9 @@ def publish_tagged_docker_images(docker_image_type, tag_name: str, current_branc | |||
docker_client.images.build(dockerfile=docker_image_info_dict[docker_image_type]['file-name'], | |||
tag=docker_image_name, | |||
path=".") | |||
if current_branch != DEFAULT_BRANCH_NAME: | |||
print(f"Since current branch {current_branch} is not equal to {DEFAULT_BRANCH_NAME} tags will not be pushed.") | |||
if is_tag_on_branch(tag_name=tag_name, branch_name=DEFAULT_BRANCH_NAME): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of tag push, tag contains check is used instead of branch name
@@ -216,23 +219,42 @@ def validate_and_extract_manual_exec_params(manual_trigger_type_param: str, tag_ | |||
return manual_trigger_type_param | |||
|
|||
|
|||
def get_image_publish_status(github_ref: str, is_test: bool): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Centralized the image publish status to manage the publish status in one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not really understand the purpose of the new publish
parameter in many of your functions. Can you please choose a better name?
with: | ||
fetch-depth: 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? Do you really need all the git history?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/citusdata/tools/runs/3653741920?check_suite_focus=true
I can not test the is_tag_on_branch since devevlop is not fetched
@@ -11,7 +11,8 @@ | |||
import gnupg | |||
import pathlib2 | |||
import requests | |||
from git import Repo | |||
from git import Repo, GitCommandError | |||
import git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please organize your imports.
Here is my suggestion:
import base64
import os
import re
import shlex
import subprocess
from datetime import datetime
from enum import Enum
from typing import Dict, List, Tuple
import git
import gnupg
import pathlib2
import requests
from git import GitCommandError, Repo
from github import Commit, Github, PullRequest, Repository
from jinja2 import Environment, FileSystemLoader
from parameters_validation import validate_parameters
from .common_validations import is_tag, is_version
from .dbconfig import RequestLog, RequestType
Imports should be divided according to what is being imported. There are generally three groups:
- standard library imports (Python’s built-in modules)
- related third party imports (modules that are installed and do not belong to the current application)
- local application imports (modules that belong to the current application)
Each group of imports should be separated by a blank space.
See https://realpython.com/absolute-vs-relative-python-imports/#styling-of-import-statements for more on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider updating your IDE to organize your imports on save, so it always keeps them in the correct format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configured my IDE and fixed as you wish
@gurkanindibay I do not really get why we need to have a really convoluted solution to this problem. I think we have 2 scenarios where we push images to DockerHub. on:
push:
branches:
- master on:
push:
tags:
- "**" In either case, we should be able to get the ref properly by using Note that you may need separate workflow definitions to allow this. Let's have a chat offline and create a better design for solving this problem. |
After building main docker images, we need to create tagged docker images such as 10.0-alpine by creating new tag on master branch
While tagging, Github Actions clones the code in detached state and when in this state we can not get current branch . Since we are using current branch to decide whether images weill published or not, and we can not use it in tag push case , we need to put tag existence case on master branch to be able to handle tag push case
Som improvements are suggested. These are in the issue below
#192