Skip to content

Commit

Permalink
Update deploy-to-eks.yaml with the Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
mvlassis committed Sep 4, 2024
1 parent 82ac4aa commit 5079d63
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy-to-aks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:

- name: Process bundle versions
id: process_bundle_versions
run: |
python scripts/gh-actions/parse_versions.py
run: python scripts/gh-actions/parse_versions.py

deploy-ckf-to-aks:
needs: preprocess-input
Expand Down
24 changes: 9 additions & 15 deletions .github/workflows/deploy-to-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,17 @@ jobs:
outputs:
processed_bundle_versions: ${{ steps.process_bundle_versions.outputs.bundle_versions }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Process bundle versions
id: process_bundle_versions
run: |
if [ -z "${{ github.event.inputs.bundle_version }}" ]; then
INPUT_VERSIONS="1.8,1.9,latest"
else
INPUT_VERSIONS="${{ github.event.inputs.bundle_version }}"
# Also remove whitespace between the entries
INPUT_VERSIONS="$(echo "$INPUT_VERSIONS" | tr -d ' ')"
fi
# Convert the comma-separated values into a JSON array
JSON_ARRAY=$(echo "[\"${INPUT_VERSIONS//,/\",\"}\"]")
echo "bundle_versions=${JSON_ARRAY}" >> $GITHUB_OUTPUT
# Output to the terminal so we can see the final value
echo "bundle_versions=${JSON_ARRAY}"
run: python scripts/gh-actions/parse_versions.py

deploy-ckf-to-eks:
needs: preprocess-input
Expand Down
8 changes: 3 additions & 5 deletions scripts/gh-actions/parse_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import sys
import json

# Parse the versions given as a comma-separated list and return a JSON array
def parse_versions(input_versions):
# Default version string if input is empty
# Default version string if the input is empty
if not input_versions:
input_versions = "1.8,1.9,latest"
else:
Expand All @@ -15,13 +16,10 @@ def parse_versions(input_versions):
return json_array

if __name__ == "__main__":
# Read the input version from the environment variable
# Read the input of the Github Action from the environment variable
input_versions = os.getenv('INPUT_BUNDLE_VERSION', '')
# Parse the versions
json_array = parse_versions(input_versions)
# Output the result to GitHub Actions
print(f"bundle_versions={json_array}")
# Write to GitHub Actions output
with open(os.environ['GITHUB_OUTPUT'], 'a') as output_file:
output_file.write(f"bundle_versions={json_array}\n")

0 comments on commit 5079d63

Please sign in to comment.