-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
122 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import shutil | ||
|
||
|
||
def copy_files(src_dir, dst_dir, base_dir): | ||
for root, _, files in os.walk(src_dir): | ||
for file in files: | ||
src = os.path.join(root, file) | ||
dst = os.path.join(dst_dir, os.path.relpath(src, base_dir)) | ||
os.makedirs(os.path.dirname(dst), exist_ok=True) | ||
shutil.copy2(src, dst) | ||
print(f"Copied {src} to {dst}") | ||
|
||
|
||
def handle_versions(base_templates, version, output_dir): | ||
for i in range(1, version + 1): | ||
version_dir = os.path.join(base_templates, f"v{i}") | ||
if not os.path.exists(version_dir): | ||
print(f"Version {i} does not exist - skipping") | ||
continue | ||
print(f"Copying version v{i} from {version_dir}") | ||
copy_files(version_dir, output_dir, version_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
base_templates = os.getenv('INPUT_BASE_TEMPLATES') | ||
custom_templates = os.getenv('INPUT_CUSTOM_TEMPLATES') | ||
version = int(os.getenv('INPUT_VERSION')) | ||
output_dir = 'tmp/templates' | ||
|
||
print(f"Base templates: {base_templates}") | ||
print(f"Custom templates: {custom_templates}") | ||
print(f"Version: {version}") | ||
print(f"Output templates: {output_dir}") | ||
|
||
handle_versions(base_templates, version, output_dir) | ||
copy_files(custom_templates, output_dir, custom_templates) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Combine Templates | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
base_templates: | ||
description: 'Base SDK templates path (without the versioned directories)' | ||
type: string | ||
default: 'sdk-repo/generator/openapi/src/main/resources/templates/expediagroup-sdk' | ||
version: | ||
description: 'Base templates version' | ||
type: number | ||
default: 1 | ||
custom_templates: | ||
description: 'Custom templates path to merge with base templates' | ||
type: string | ||
default: '' | ||
combined_templates_key: | ||
description: 'Key to the combined templates artifact' | ||
type: string | ||
default: 'templates' | ||
|
||
jobs: | ||
combine-templates: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Combine templates | ||
run: python .github/scripts/combine_templates.py | ||
env: | ||
INPUT_BASE_TEMPLATES: ${{ github.event.inputs.base_templates }} | ||
INPUT_CUSTOM_TEMPLATES: ${{ github.event.inputs.custom_templates }} | ||
INPUT_VERSION: ${{ github.event.inputs.version }} | ||
INPUT_OUTPUT_DIR: 'tmp/templates' | ||
|
||
- name: Upload combined templates | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ inputs.combined_templates_key }} | ||
path: tmp/templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.