-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DH-301] Python script to replace bash scaffolding in CI/CD and simplify github workflows #6035
[DH-301] Python script to replace bash scaffolding in CI/CD and simplify github workflows #6035
Conversation
…match the style of the rest of the python i write. match the style of the rest of the python i write
i also thought about consolidating the |
output showing how the script interacts w/the env vars that are set by the get-labels-on-push github action:
|
.github/workflows/deploy-hubs.yaml
Outdated
# | ||
# Otherwise, just check to see if the PR labels contain any hubs, | ||
# and if so, deploy just those hubs to staging. | ||
if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@felder : sanity check here. the github action that grabs labels from a push exports them to env vars in the format of GITHUB_PR_LABEL_<whatever>=1
. in this case, i want to check for the labels of jupyterhub-deployment
and/or hub-images
(stored as the vars in the code snippet above).
if i want to check if these are indeed set, the way i do it here (if [[ -n ${GITHUB_PR_LABEL_HUB_IMAGES} || -n ${GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT} ]]
) is correct, yes?
(i did a bunch of testing on the CLI and this seems to give us what we want but a 2nd pair of eyes is always nice etc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shaneknapp -n evaluates to true if the variable is not set to the empty string. You may want to use -v instead which evaluates to true if the variable is set. -v also expects the name of the variable as opposed to an expansion of the variable.
So you may want to tryif [[ -v GITHUB_PR_LABEL_HUB_IMAGES || -v GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]]
Example:
#!/usr/bin/env bash
TEST=""
if [[ ! -n ${TEST} ]]; then
echo "TEST is empty"
fi
if [[ -v TEST ]]; then
echo "TEST is set"
fi
unset TEST
if [[ ! -v TEST ]]; then
echo "TEST is no longer set"
fi
ras-29-57:~ felder$ ./test.sh
TEST is empty
TEST is set
TEST is no longer set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, lemme try that... i'll set some labels to test this when i merge to staging
by adding a small python script to determine if all hubs, or just a subset need to be deployed we can now use a single workflow to do this instead of two.