Skip to main content

Enterprise Server 3.22 est actuellement disponible en tant que version candidate.

Automating an upgrade

You can automate upgrade operations using the REST API or a GitHub CLI extension.

You can upgrade your GitHub Enterprise Server instance using the Manage GitHub Enterprise Server API or the gh es extension for GitHub CLI. These tools automate the process of downloading the upgrade package, running pre-upgrade checks, and applying the new version.

Prerequisites

Automating an upgrade using the REST API

  1. Download the upgrade package.

    curl -L \
      -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/download \
      -d '{"version":"VERSION"}'
    
  2. Confirm the download has completed before proceeding.

    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/download/status
    

    Wait until status shows COMPLETED.

  3. Apply the upgrade's pre-upgrade phase.

    curl -L \
      -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/apply \
      -d '{"version":"VERSION", "phase":"pre-upgrade"}'
    
  4. Monitor the pre-upgrade phase until it completes.

    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      "https://HOSTNAME:8443/manage/v1/upgrade/status?is_verbose=true"
    

    Wait until status shows completed and is_running shows false.

  5. Enable maintenance mode.

    curl -L \
      -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/maintenance \
      -d '{"enabled":true}'
    
  6. Apply the upgrade's upgrade phase.

    curl -L \
      -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/apply \
      -d '{"version":"VERSION", "phase":"upgrade"}'
    
  7. Confirm the release version has been updated.

    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/version
    
  8. Disable maintenance mode.

    curl -L \
      -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/maintenance \
      -d '{"enabled":false}'
    

Automating an upgrade using the GitHub CLI extension

  1. Download the upgrade package. To download a specific version, specify the --version flag; otherwise, the latest available version is downloaded.

    # Download a specific version
    gh es upgrade download --version VERSION
    
    # Or download the latest available version
    gh es upgrade download
    
  2. Confirm the download has completed before proceeding.

    gh es upgrade download status
    

    Wait until status shows COMPLETED.

  3. Apply the upgrade's pre-upgrade phase.

    gh es upgrade apply --version VERSION --phase pre-upgrade
    
  4. Monitor the pre-upgrade phase until it completes.

    gh es upgrade status --verbose
    

    Wait until status shows completed and is_running shows false.

  5. Enable maintenance mode.

    gh es maintenance set --enabled true
    
  6. Apply the upgrade's upgrade phase.

    gh es upgrade apply --version VERSION --phase upgrade
    
  7. Confirm the release version has been updated.

    gh es release version
    
  8. Disable maintenance mode.

    gh es maintenance set --enabled false
    

Upgrading a high availability deployment

For instances with a high availability (HA) replica, the download and pre-upgrade phases are non-disruptive and can run across all nodes at once. UUID targeting is only needed for the upgrade phase itself, which triggers the reboot. This lets you control the order nodes reboot in: upgrade the replica first, then the primary.

To retrieve node UUIDs, run gh es config get-metadata or query GET /manage/v1/config/nodes.

Upgrading a high availability deployment using the GitHub CLI

  1. Download the package to all nodes.

    gh es upgrade download --version VERSION
    
  2. Wait for the download to complete on all nodes.

    gh es upgrade download status
    
  3. Run the pre-upgrade phase on all nodes at once. This phase is non-disruptive.

    gh es upgrade apply --version VERSION --phase pre-upgrade
    
  4. Wait for the pre-upgrade phase to complete.

    gh es upgrade status --verbose
    
  5. Enable maintenance mode.

    gh es maintenance set --enabled true
    
  6. Stop replication on the replica.

    ghe-repl-stop
    
  7. Upgrade the primary first, which triggers the reboot, then monitor its progress.

    gh es upgrade apply --version VERSION --phase upgrade --uuid PRIMARY-UUID
    gh es upgrade status --uuid PRIMARY-UUID --verbose
    
  8. After the primary finishes, upgrade the replica, then monitor its progress.

    gh es upgrade apply --version VERSION --phase upgrade --uuid REPLICA-UUID
    gh es upgrade status --uuid REPLICA-UUID --verbose
    
  9. Start replication again on the replica.

    ghe-repl-start
    
  10. Verify replication health and the version, then disable maintenance mode.

    gh es replication status
    gh es release version
    gh es maintenance set --enabled false
    

Upgrading a high availability deployment using the REST API

  1. Download the package to all nodes.

    curl -L -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/download \
      -d '{"version":"VERSION"}'
    
  2. Wait for the download to complete on all nodes.

    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/download/status
    
  3. Run the pre-upgrade phase on all nodes at once. This phase is non-disruptive.

    curl -L -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/apply \
      -d '{"version":"VERSION","phase":"pre-upgrade"}'
    
  4. Wait for the pre-upgrade phase to complete.

    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      "https://HOSTNAME:8443/manage/v1/upgrade/status?is_verbose=true"
    
  5. Enable maintenance mode.

    curl -L -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/maintenance \
      -d '{"enabled":true}'
    
  6. Stop replication on the replica.

    ghe-repl-stop
    
  7. Upgrade the primary first, which triggers the reboot, then monitor its progress.

    curl -L -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/apply \
      -d '{"version":"VERSION","phase":"upgrade","uuid":"PRIMARY-UUID"}'
    
    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      "https://HOSTNAME:8443/manage/v1/upgrade/status?uuid=PRIMARY-UUID&is_verbose=true"
    
  8. After the primary finishes, upgrade the replica, then monitor its progress.

    curl -L -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/upgrade/apply \
      -d '{"version":"VERSION","phase":"upgrade","uuid":"REPLICA-UUID"}'
    
    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      "https://HOSTNAME:8443/manage/v1/upgrade/status?uuid=REPLICA-UUID&is_verbose=true"
    
  9. Start replication again on the replica.

    ghe-repl-start
    
  10. Verify replication health and the version, then disable maintenance mode.

    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/replication/status
    
    curl -L \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/version
    
    curl -L -X POST \
      -u "api_key:ROOT-SITE-ADMINISTRATOR-PASSWORD" \
      -H "Content-Type: application/json" \
      https://HOSTNAME:8443/manage/v1/maintenance \
      -d '{"enabled":false}'