mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 17:50:20 +00:00
Fix update winrepo script on 3006.x
This commit is contained in:
parent
ce9d09bc9c
commit
c6991e22ce
2 changed files with 17 additions and 3 deletions
3
.github/workflows/release-update-winrepo.yml
vendored
3
.github/workflows/release-update-winrepo.yml
vendored
|
@ -41,9 +41,12 @@ jobs:
|
|||
- name: Add Version to Minion Definition File
|
||||
working-directory: salt
|
||||
run: |
|
||||
pwd
|
||||
ls -al ../winrepo/salt-minion.sls
|
||||
python .github/workflows/scripts/update_winrepo.py \
|
||||
--file ../winrepo/salt-minion.sls \
|
||||
--version ${{ inputs.salt-version || github.ref_name }}
|
||||
grep ${{ inputs.salt-version || github.ref_name }} ../winrepo/salt-minion.sls
|
||||
|
||||
- name: Commit Changes
|
||||
working-directory: winrepo
|
||||
|
|
17
.github/workflows/scripts/update_winrepo.py
vendored
17
.github/workflows/scripts/update_winrepo.py
vendored
|
@ -1,8 +1,10 @@
|
|||
import argparse
|
||||
import os
|
||||
|
||||
print("Update winrepo script")
|
||||
|
||||
# Where are we
|
||||
print(os.getcwd())
|
||||
print(f"Current working directory: {os.getcwd()}")
|
||||
|
||||
arg_parser = argparse.ArgumentParser()
|
||||
arg_parser.add_argument("-f", "--file", help="the winrepo file to edit")
|
||||
|
@ -12,10 +14,15 @@ args = arg_parser.parse_args()
|
|||
file = args.file
|
||||
version = args.version
|
||||
|
||||
print("Args:")
|
||||
print(f"- file: {file}")
|
||||
print(f"- version: {version}")
|
||||
|
||||
if version.startswith("v"):
|
||||
version = version[1:]
|
||||
|
||||
with open(file) as f:
|
||||
print(f"Opening file: {file}")
|
||||
current_contents = f.readlines()
|
||||
|
||||
new_contents = []
|
||||
|
@ -23,9 +30,13 @@ new_contents = []
|
|||
added = False
|
||||
for line in current_contents:
|
||||
new_contents.append(line)
|
||||
if "for version in [" in line and not added:
|
||||
new_contents.append(f" '{version}',\n")
|
||||
if "load_yaml as versions_relenv" in line and not added:
|
||||
print(f"Adding version: {version}")
|
||||
new_contents.append(f"- {version}\n")
|
||||
added = True
|
||||
|
||||
with open(file, "w") as f:
|
||||
print(f"Writing file: {file}")
|
||||
f.writelines(new_contents)
|
||||
|
||||
print("Update winrepo script complete")
|
||||
|
|
Loading…
Add table
Reference in a new issue