from config.project_config import PROJECT_NAME, PROJECT_PORT # 重写gitlab配置文件 def write_gitlab_config(): with open('.gitlab-ci.yml') as f: content = f.read() content = content.replace('PROJECT_NAME', PROJECT_NAME) content = content.replace('PROJECT_PORT', PROJECT_PORT) f.close() with open('.gitlab-ci.yml', 'w') as f: f.write(content) f.close() # 重写docker配置文件 def write_docker_config(): with open('Dockerfile') as f: content = f.read() content = content.replace('PROJECT_NAME', PROJECT_NAME) f.close() with open('Dockerfile', 'w') as f: f.write(content) f.close() if __name__ == '__main__': write_gitlab_config() write_docker_config()