diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..e29dee3 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,40 @@ +# Repository Sync Script + +This script automates the process of committing and pushing changes across multiple image pipeline repositories. + +## Usage + +```bash +./scripts/sync-repos.sh +``` + +The script will: +1. Look for changes in each repository +2. Commit changes with predefined commit messages +3. Push to both 'hpw' and 'origin' remotes + +## Prerequisites + +- Git repositories must be cloned in the same parent directory +- Both 'hpw' and 'origin' remotes must be configured +- Script must be run from the aws-image-pipeline directory +- Appropriate git credentials/SSH keys must be configured + +## Modifying Commit Messages + +To update the commit messages, edit the `REPOS` array in the script. Each repository has an associated commit message: + +```bash +declare -A REPOS=( + ["aws-image-pipeline"]="your commit message here" + ["image-pipeline-ansible-playbooks"]="your commit message here" + ["linux-image-pipeline"]="your commit message here" +) +``` + +## Error Handling + +The script will: +- Continue even if one repository fails +- Report failures to push to either remote +- Skip repositories with no changes \ No newline at end of file diff --git a/scripts/sync-repos.sh b/scripts/sync-repos.sh new file mode 100755 index 0000000..62cd043 --- /dev/null +++ b/scripts/sync-repos.sh @@ -0,0 +1,51 @@ +#!/bin/bash +set -e + +# Directory containing all repos +BASE_DIR=/home/a/arnol377/git + +# Define repositories and their commit messages +declare -A REPOS +REPOS["aws-image-pipeline"]="fix: update morpheus module config to use proper device mappings for NVMe EBS volumes" +REPOS["image-pipeline-ansible-playbooks"]="fix: update volume mounting to handle NVMe device mapping and add enhanced error checking" +REPOS["linux-image-pipeline"]="fix: update packer configuration to properly handle root volume and NVMe device mappings" + +# Function to commit and push changes +commit_and_push() { + local repo=$1 + local message=$2 + local dir="${BASE_DIR}/${repo}" + + echo "Processing ${repo}..." + + if [ ! -d "$dir" ]; then + echo "Error: Directory $dir does not exist" + return 1 + fi + + cd "$dir" + + # Check if there are changes to commit + if git status --porcelain | grep -q '^'; then + echo "Changes detected in ${repo}, committing..." + git add . + git commit -m "$message" + + # Push to both remotes + echo "Pushing to hpw..." + git push hpw main || echo "Warning: Failed to push to hpw remote" + + echo "Pushing to origin..." + git push origin main || echo "Warning: Failed to push to origin remote" + else + echo "No changes to commit in ${repo}" + fi +} + +# Main execution +for repo in "${!REPOS[@]}"; do + commit_message=${REPOS[$repo]} + commit_and_push "$repo" "$commit_message" || echo "Failed to process ${repo}" +done + +echo "All repositories processed successfully!" \ No newline at end of file