Backup legacy workflow files.
(self)
| 133 | return False |
| 134 | |
| 135 | def _backup_legacy_workflows(self) -> bool: |
| 136 | """Backup legacy workflow files.""" |
| 137 | try: |
| 138 | legacy_files = ["ci.yml", "release.yml"] |
| 139 | |
| 140 | if not self.dry_run: |
| 141 | self.backup_dir.mkdir(parents=True, exist_ok=True) |
| 142 | |
| 143 | backed_up_files = [] |
| 144 | |
| 145 | for legacy_file in legacy_files: |
| 146 | legacy_path = self.workflows_dir / legacy_file |
| 147 | |
| 148 | if legacy_path.exists(): |
| 149 | backup_path = self.backup_dir / f"{legacy_file}.backup-{datetime.now().strftime('%Y%m%d-%H%M%S')}" |
| 150 | |
| 151 | if not self.dry_run: |
| 152 | shutil.copy2(legacy_path, backup_path) |
| 153 | |
| 154 | backed_up_files.append(legacy_file) |
| 155 | print(f" [BACKUP] {legacy_file} -> {backup_path.name}") |
| 156 | |
| 157 | if not backed_up_files: |
| 158 | print(" [INFO] No legacy workflow files found to backup") |
| 159 | |
| 160 | return True |
| 161 | |
| 162 | except Exception as e: |
| 163 | self.steps[0].error = str(e) |
| 164 | return False |
| 165 | |
| 166 | def _validate_modular_workflows(self) -> bool: |
| 167 | """Validate that all modular workflow files exist and are valid.""" |