|
7 | 7 | all external action versions used, then updates:
|
8 | 8 | 1. Hardcoded action versions in pr-checks/sync.py
|
9 | 9 | 2. Action version references in template files in pr-checks/checks/
|
10 |
| -3. Action version references in regular workflow files |
11 | 10 |
|
12 | 11 | The script automatically detects all actions used in generated workflows and
|
13 | 12 | preserves version comments (e.g., # v1.2.3) when syncing versions.
|
14 | 13 |
|
15 | 14 | This ensures that when Dependabot updates action versions in generated workflows,
|
16 |
| -those changes are properly synced back to the source templates. |
| 15 | +those changes are properly synced back to the source templates. Regular workflow |
| 16 | +files are updated directly by Dependabot and don't need sync-back. |
17 | 17 | """
|
18 | 18 |
|
19 | 19 | import os
|
@@ -132,45 +132,6 @@ def update_template_files(checks_dir: str, action_versions: Dict[str, str]) -> L
|
132 | 132 | return modified_files
|
133 | 133 |
|
134 | 134 |
|
135 |
| -def update_regular_workflows(workflow_dir: str, action_versions: Dict[str, str]) -> List[str]: |
136 |
| - """ |
137 |
| - Update action versions in regular (non-generated) workflow files |
138 |
| - |
139 |
| - Args: |
140 |
| - workflow_dir: Path to .github/workflows directory |
141 |
| - action_versions: Dictionary of action names to versions (may include comments) |
142 |
| - |
143 |
| - Returns: |
144 |
| - List of files that were modified |
145 |
| - """ |
146 |
| - modified_files = [] |
147 |
| - |
148 |
| - # Get all workflow files that are NOT generated (don't start with __) |
149 |
| - all_files = glob.glob(os.path.join(workflow_dir, "*.yml")) |
150 |
| - regular_files = [f for f in all_files if not os.path.basename(f).startswith("__")] |
151 |
| - |
152 |
| - for file_path in regular_files: |
153 |
| - with open(file_path, 'r') as f: |
154 |
| - content = f.read() |
155 |
| - |
156 |
| - original_content = content |
157 |
| - |
158 |
| - # Update action versions |
159 |
| - for action_name, version_with_comment in action_versions.items(): |
160 |
| - # Look for patterns like 'uses: actions/setup-node@v4' or 'uses: actions/setup-node@sha # comment' |
161 |
| - pattern = rf"(uses:\s+{re.escape(action_name)})@([^@\n]+)" |
162 |
| - replacement = rf"\1@{version_with_comment}" |
163 |
| - content = re.sub(pattern, replacement, content) |
164 |
| - |
165 |
| - if content != original_content: |
166 |
| - with open(file_path, 'w') as f: |
167 |
| - f.write(content) |
168 |
| - modified_files.append(file_path) |
169 |
| - print(f"Updated {file_path}") |
170 |
| - |
171 |
| - return modified_files |
172 |
| - |
173 |
| - |
174 | 135 | def main():
|
175 | 136 | parser = argparse.ArgumentParser(description="Sync action versions from generated workflows back to templates")
|
176 | 137 | parser.add_argument("--dry-run", action="store_true", help="Show what would be changed without making changes")
|
@@ -214,10 +175,6 @@ def main():
|
214 | 175 | template_modified = update_template_files(str(checks_dir), action_versions)
|
215 | 176 | modified_files.extend(template_modified)
|
216 | 177 |
|
217 |
| - # Update regular workflow files |
218 |
| - workflow_modified = update_regular_workflows(str(workflow_dir), action_versions) |
219 |
| - modified_files.extend(workflow_modified) |
220 |
| - |
221 | 178 | if modified_files:
|
222 | 179 | print(f"\nSync completed. Modified {len(modified_files)} files:")
|
223 | 180 | for file_path in modified_files:
|
|
0 commit comments