Skip to content
Snippets Groups Projects
Select Git revision
  • f8da004aab59812a4ea83e971a59d22385fa0bdd
  • develop default protected
  • production protected
  • nixpkgs-upgrade-2025-06-16
  • nixpkgs-upgrade-2024-12-23
  • 190-our-regular-updates-fill-up-the-servers-boot-partitions
  • nixpkgs-upgrade-2024-10-14
  • hro-cloud protected
  • 162.flexible-grafana-module
  • nixpkgs-upgrade-2024-05-13
  • nixpkgs-upgrade-2024-04-22
  • nixpkgs-upgrade-2024-03-25
  • nixpkgs-upgrade-2024-03-18
  • nixpkgs-upgrade-2024-03-11
  • nixpkgs-upgrade-2024-03-04
  • 163.jp-to-ben-for-prod
  • nixpkgs-upgrade-2024-02-26
  • 164.grafana-alert-rules
  • 157.authorize-new-hro-key
  • nixpkgs-upgrade-2024-02-19
  • nixpkgs-upgrade-2024-02-12
21 results

update-production

Blame
  • update-production 4.18 KiB
    #!/usr/bin/env nix-shell
    #!nix-shell -i bash -p git curl python3
    
    set -eux -o pipefail
    
    main() {
        local TOKEN=$1
        shift
        local SERVER_URL=$1
        shift
        local PROJECT_ID=$1
        shift
        local SOURCE_BRANCH=$1
        shift
        local TARGET_BRANCH=$1
        shift
    
        # Make sure the things we want to talk about are locally known.  GitLab
        # seems to prefer to know about as few refs as possible.
        checkout_git_ref "$SOURCE_BRANCH"
        checkout_git_ref "$TARGET_BRANCH"
    
        # If there have been no changes we'll just abandon this update.
        if ! ensure_changes "$SOURCE_BRANCH" "$TARGET_BRANCH"; then
    	echo "No changes."
    	exit 0
        fi
    
        local NOTES=$(describe_update "$SOURCE_BRANCH" "$TARGET_BRANCH")
    
        create_merge_request "$TOKEN" "$SERVER_URL" "$PROJECT_ID" "$SOURCE_BRANCH" "$TARGET_BRANCH" "$NOTES"
    }
    
    checkout_git_ref() {
        local REF=$1
        shift
    
        git fetch origin "$REF"
    }
    
    ensure_changes() {
        local SOURCE_BRANCH=$1
        shift
        local TARGET_BRANCH=$1
        shift
    
        if [ "$(git rev-parse origin/"$SOURCE_BRANCH")" = "$(git rev-parse origin/"$TARGET_BRANCH")" ]; then
    	return 1
        fi
    }
    
    describe_merge_request() {
        git show $rev | grep 'See merge request' | sed -e 's/See merge request //' | tr -d '[:space:]'
    }
    
    describe_merge_requests() {
        local RANGE=$1
        shift
        local TARGET=$1
        shift
    
        # Find all of the relevant merge revisions
        local onelines=$(git log --merges --first-parent -m --oneline "$RANGE" | grep "into '$TARGET'")
    
        # Describe each merge revision
        local IFS=$'\n'
        for line in $onelines; do
    	local rev=$(echo "$line" | cut -d ' ' -f 1)
    	echo -n "* "
    	describe_merge_request $rev