Skip to content

Commit

Permalink
Merge pull request #5 from yibo-long/add-path-as-args
Browse files Browse the repository at this point in the history
Add change-paths
  • Loading branch information
yibo-long authored Jan 16, 2024
2 parents 0d99f84 + 363a229 commit 8fc5d69
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/scripts/create-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,16 @@ def merge_config(final_config, config_path):
final_config['workflows'].update(config_yaml['workflows'])


def send_continuation_file(config_path):
print(f'start workflow in {config_path}')
with open(config_path, 'r') as config_file:
content = config_file.read()
res = requests.post(
f'https://{CIRCLECI_DOMAIN}/api/v2/pipeline/continue',
json={
'continuation-key': CIRCLE_CONTINUATION_KEY,
'configuration': content
},
headers={
'Content-Type': 'application/json',
'Accept': 'application/json',
}
)
print(res)
print(res.text)


def send_continuation(config):
def send_continuation(config, changes):
print(f'start workflow as {config}')
res = requests.post(
f'https://{CIRCLECI_DOMAIN}/api/v2/pipeline/continue',
json={
'continuation-key': CIRCLE_CONTINUATION_KEY,
'configuration': json.dumps(config)
'configuration': json.dumps(config),
'parameters': {
'change-paths': ','.join(changes)
}
},
headers={
'Content-Type': 'application/json',
Expand Down Expand Up @@ -156,14 +140,18 @@ def create_config(head, base):
'trigger-path': {
'type': 'string',
'default': ''
},
'change-paths': {
'type': 'string',
'default': ''
}
}
}
for config_path in config_paths:
if check_config_match(config_path, changes):
merge_config(final_config, config_path)
if final_config['workflows']:
send_continuation(final_config)
send_continuation(final_config, changes)
else:
print('no workflow to be scheduled, skip creating continuation workflow')

Expand Down

0 comments on commit 8fc5d69

Please sign in to comment.