#!/usr/bin/env python # # Deploy environment/manifest files to the release directory. # import os import sys import shutil def main(): dest = sys.argv[1] files = sys.argv[2:] publish_from_branches = os.environ.get('PUBLISH_FROM_BRANCHES', '') branch = os.environ.get('CI_COMMIT_BRANCH', None) tag = os.environ.get('CI_COMMIT_TAG', None) allow_publish = ((tag is not None) or ((branch is not None) and (branch in publish_from_branches))) if not allow_publish: print('Publishing is only allowed from tags or ' f'these branches: {publish_from_branches}') sys.exit(1) if tag is not None: print(f'Publishing files from tag {tag}') else: print(f'Publishing files from branch {branch}') for src in files: print(f'Copying {src} to {dest}') shutil.copy(src, dest) if __name__ == '__main__': main()