Created
November 21, 2024 14:30
-
-
Save Juanpa0128j/f28167dd805dcddbc2a6c20ef6a8640b to your computer and use it in GitHub Desktop.
Performs env update, add, comit and push in a single call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function autopush() { | |
| # Usage: autopush "commit message" branch_name path_to_your_repo | |
| # Check if commit message and branch name are provided | |
| if [ "$#" -ne 3 ]; then | |
| echo "Usage: autopush \"commit message\" branch_name path_to_your_repo" | |
| else | |
| # Set variables from arguments | |
| COMMIT_MSG="$1" | |
| BRANCH_NAME="$2" | |
| REPO_PATH="$3" | |
| YAML_FILE="environment.yml" | |
| # Step 1: Export the Conda environment to a YAML file | |
| echo "Exporting Conda environment..." | |
| conda env export | sed '/^prefix: /d' > "$REPO_PATH/$YAML_FILE" | |
| # Step 2: Navigate to the repository and commit the changes | |
| cd "$REPO_PATH" || exit | |
| git add . | |
| git commit -m "$COMMIT_MSG" | |
| # Step 3: Push the changes to the specified branch | |
| echo "Pushing changes to $BRANCH_NAME..." | |
| git push origin "$BRANCH_NAME" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment