Skip to content

Instantly share code, notes, and snippets.

@KyMidd
Created May 31, 2023 21:08
Show Gist options
  • Select an option

  • Save KyMidd/ac00363df2687c3f4bbc0e2e683cd78a to your computer and use it in GitHub Desktop.

Select an option

Save KyMidd/ac00363df2687c3f4bbc0e2e683cd78a to your computer and use it in GitHub Desktop.
- name: Specify pods to deploy using regex ${{ github.event.inputs.pod-selection-regex }}
id: set-targeted-pods
run: |
# Read TF apply workfile as var
WORKFILE=$(cat ./.github/workflows/tf-deploy.yml)
# Get all targateable pods from workflow file
ALL_PODS=$(echo "$WORKFILE" | yq .on.workflow_dispatch.inputs.location.options | cut -d " " -f 2)
# If pod-selection-regex set to wildcard, select all pods
if [[ ${{ github.event.inputs.pod-selection-regex }} == "*" ]]; then
echo "Wildcard used to select all pods, selecting all pods"
TARGETED_PODS=$ALL_PODS
else
echo "Wildcard not used to select all pods, selecting pods using regex"
TARGETED_PODS=$(echo "$ALL_PODS" | grep -E "${{ github.event.inputs.pod-selection-regex }}" )
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment