Remove additional files
This commit is contained in:
Родитель
9a8c195637
Коммит
b7176240fc
|
@ -1,4 +0,0 @@
|
|||
.git/
|
||||
.github/
|
||||
.gitattributes
|
||||
.gitignore
|
|
@ -1,7 +0,0 @@
|
|||
# Backup-Utils owned by lifecycle AOR
|
||||
* @github/ghes-lifecycle
|
||||
# Actions related backups and restores
|
||||
# /share/github-backup-utils/*-actions @github/ghes-lifecycle @github/<TBD>
|
||||
# Git related backups and restores
|
||||
# /share/github-backup-utils/*-repositories @github/ghes-lifecycle @github/<TBD>
|
||||
# /share/github-backup-utils/*-git-hooks @github/ghes-lifecycle @github/<TBD>
|
|
@ -1,33 +0,0 @@
|
|||
name: 'Trigger a CI Job on Janky'
|
||||
description: 'Action to trigger and poll a Janky CI job'
|
||||
inputs:
|
||||
janky-token:
|
||||
description: 'Token for making request to Janky'
|
||||
required: true
|
||||
job-name:
|
||||
description: 'The name of the job to run'
|
||||
required: true
|
||||
branch-name:
|
||||
description: 'The name of the branch to use'
|
||||
required: true
|
||||
force:
|
||||
description: 'Force the job to run even if it is already passed'
|
||||
required: false
|
||||
envVars:
|
||||
description: 'Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3'
|
||||
required: false
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- uses: actions/setup-go@a3d889c34c5d4e071b33595c5fe8edfcaaad8260
|
||||
with:
|
||||
go-version: '1.21'
|
||||
- run: |
|
||||
go run main.go \
|
||||
-token ${{ inputs.janky-token }} \
|
||||
-job ${{ inputs.job-name }} \
|
||||
-branch ${{ inputs.branch-name }} \
|
||||
-force ${{ inputs.force }} \
|
||||
-envVars ${{ inputs.envVars }}
|
||||
shell: bash
|
||||
working-directory: .github/actions/proxy-janky-build
|
|
@ -1,7 +0,0 @@
|
|||
module github.com/github/enterprise2/actions/proxy-janky-build
|
||||
|
||||
go 1.21
|
||||
|
||||
require github.com/hashicorp/go-retryablehttp v0.7.2
|
||||
|
||||
require github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
|
@ -1,9 +0,0 @@
|
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
@ -1,180 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-retryablehttp"
|
||||
)
|
||||
|
||||
// Define our Janky Response Structs
|
||||
type JankyBuildStruct struct {
|
||||
Result string
|
||||
Url string
|
||||
}
|
||||
type JankyStatusStruct struct {
|
||||
Id string
|
||||
Green bool
|
||||
Completed bool
|
||||
StartedAt string
|
||||
CompletedAt string
|
||||
Sha string
|
||||
BuildableName string
|
||||
}
|
||||
|
||||
const (
|
||||
pollWaitTime = 10 * time.Second
|
||||
jankyPollTimeout = 5 * time.Hour
|
||||
jankyHttpRetryMax = 5
|
||||
jankyUrl = "https://janky.githubapp.com"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Parse command-line arguments
|
||||
job := flag.String("job", "", "Name of the Janky job")
|
||||
token := flag.String("token", "", "Name of the Janky token")
|
||||
branch := flag.String("branch", "", "Name of the Git branch")
|
||||
force := flag.String("force", "false", "Force a build even if one is already passed")
|
||||
envVars := flag.String("envVars", "", "Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3")
|
||||
flag.Parse()
|
||||
|
||||
// Validate command-line arguments
|
||||
if *job == "" || *token == "" || *branch == "" {
|
||||
log.Fatal("job, token and branch flags must be specified")
|
||||
}
|
||||
|
||||
// Set up the token + request payload
|
||||
authToken := base64.StdEncoding.EncodeToString([]byte(":" + *token))
|
||||
type buildRequestObject struct {
|
||||
BuildableName string `json:"buildable_name"`
|
||||
BranchName string `json:"branch_name"`
|
||||
Force string `json:"force"`
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
}
|
||||
|
||||
requestBody := buildRequestObject{
|
||||
BuildableName: *job,
|
||||
BranchName: *branch,
|
||||
Force: *force,
|
||||
}
|
||||
|
||||
// Parse the envVars flag into a map and add to the request payload
|
||||
fmt.Println("Environment Variables:")
|
||||
fmt.Println(*envVars)
|
||||
if *envVars != "" {
|
||||
envVarsMap := make(map[string]string)
|
||||
for _, envVar := range strings.Split(*envVars, ",") {
|
||||
envVarSplit := strings.Split(envVar, "=")
|
||||
envVarsMap[envVarSplit[0]] = envVarSplit[1]
|
||||
}
|
||||
requestBody.EnvVars = envVarsMap
|
||||
}
|
||||
|
||||
payloadBytes, err := json.Marshal(requestBody)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to marshal the JSON payload!\n" + err.Error())
|
||||
}
|
||||
|
||||
// Send build request to Janky
|
||||
buildRequest, err := http.NewRequest("POST", jankyUrl+"/api/builds", bytes.NewBuffer(payloadBytes))
|
||||
if err != nil {
|
||||
log.Fatal("Failed to create build request!\n" + err.Error())
|
||||
}
|
||||
buildRequest.Header.Set("Content-Type", "application/json")
|
||||
buildRequest.Header.Set("Authorization", "Basic "+authToken)
|
||||
retryClient := retryablehttp.NewClient() //nolint:all
|
||||
retryClient.RetryMax = jankyHttpRetryMax
|
||||
retryClient.Logger = nil // disable debug logging
|
||||
client := retryClient.StandardClient() // uses *http.Client
|
||||
resp, err := client.Do(buildRequest)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to send build request!\n" + err.Error())
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatal("Error reading build response!\n" + err.Error())
|
||||
}
|
||||
|
||||
// Check if the build was triggered successfully
|
||||
if resp.StatusCode == 404 {
|
||||
log.Fatal("Failed to trigger build! Either " + *job + " is not the name of a Janky job or " + *branch + " is not a branch for the repository that job belongs to.")
|
||||
}
|
||||
if resp.StatusCode != 201 {
|
||||
log.Fatal("Failed to trigger build! Got exception: " + string(body))
|
||||
}
|
||||
|
||||
// Parse the build request response
|
||||
var buildResponse JankyBuildStruct
|
||||
json.Unmarshal(body, &buildResponse)
|
||||
log.Println("Succesfully triggered janky!\n" + buildResponse.Result)
|
||||
|
||||
// Parse the request response for the buildId
|
||||
r, err := regexp.Compile("/[0-9]+/")
|
||||
if err != nil {
|
||||
log.Fatal("Failed to trigger build!\n" + err.Error())
|
||||
}
|
||||
buildId := strings.Trim(r.FindString(buildResponse.Result), "/")
|
||||
|
||||
// Setup our second HTTP client for reuse in during status polling
|
||||
jankyStatusUrl := jankyUrl + "/api/" + buildId + "/status"
|
||||
statusRequest, err := http.NewRequest("GET", jankyStatusUrl, nil)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to create status request!\n" + err.Error())
|
||||
}
|
||||
statusRequest.Header.Set("Content-Type", "application/json")
|
||||
statusRequest.Header.Set("Authorization", "Basic "+authToken)
|
||||
retryClient2 := retryablehttp.NewClient() //nolint:all
|
||||
retryClient2.RetryMax = jankyHttpRetryMax
|
||||
retryClient2.Logger = nil // disable debug logging
|
||||
client2 := retryClient2.StandardClient() // uses *http.Client
|
||||
|
||||
// Wait for a completed status from Janky or break the loop after a certain amount of time
|
||||
timeout := time.NewTimer(jankyPollTimeout)
|
||||
poll := time.NewTicker(pollWaitTime)
|
||||
|
||||
jobLoop:
|
||||
for {
|
||||
select {
|
||||
case <-timeout.C:
|
||||
log.Fatal("Failed to poll for build status after " + jankyPollTimeout.String() + "hours")
|
||||
case <-poll.C:
|
||||
// Send build status request to Janky
|
||||
statusResponse, err := client2.Do(statusRequest)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to send status request!\n" + err.Error())
|
||||
}
|
||||
defer statusResponse.Body.Close()
|
||||
statusBody, err := io.ReadAll(statusResponse.Body)
|
||||
if err != nil {
|
||||
log.Fatal("Error reading status response!\n" + err.Error())
|
||||
}
|
||||
|
||||
// Parse the status response for a green completed build
|
||||
var jankyStatusResponse JankyStatusStruct
|
||||
json.Unmarshal(statusBody, &jankyStatusResponse)
|
||||
//fmt.Println("Janky Status Response:")
|
||||
//fmt.Println(string(statusBody))
|
||||
if jankyStatusResponse.Completed && jankyStatusResponse.Green {
|
||||
log.Println("Janky build Succeeded!")
|
||||
break jobLoop
|
||||
}
|
||||
if jankyStatusResponse.Completed && !jankyStatusResponse.Green {
|
||||
log.Fatal("Build failed, see Janky for more info: " + buildResponse.Url)
|
||||
}
|
||||
|
||||
// wait for a bit and try again
|
||||
log.Println("Build still in progress, will poll for status again in [" + pollWaitTime.String() + "]")
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "github-actions" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
|
@ -1,40 +0,0 @@
|
|||
<!-- Welcome to backup-utils-private repo and Thanks for contributing!
|
||||
|
||||
Note: Merging to the master branch will include your change in a future (unreleased) version of backup-utils. If the change needs to be shipped to the current release versions it will need to be backported. For more information, see the backport guide https://github.com/github/enterprise-releases/blob/master/docs/backport-an-existing-pr.md
|
||||
|
||||
If you have any questions we can be found in the #ghes-backup-utils Slack channel.
|
||||
-->
|
||||
|
||||
<!--
|
||||
Additional notes regarding CI:
|
||||
- All required CIs needs to be pass before merging PR
|
||||
- Integration test will run against enterprise2 repo with environment variable, do not re-run directly from janky or Github CI, please use Actions to re-run the failed tests
|
||||
- If you are making changes impacts cluster, please add `cluster` label or `[cluster]` in your PR title so it will trigger optional cluster integration test. Those tests will take about 3 hours so relax and come back later to check the results. ;)
|
||||
-->
|
||||
|
||||
# PR Details
|
||||
|
||||
## Description
|
||||
<!--
|
||||
[Please fill out a brief description of the change being made]
|
||||
-->
|
||||
## Testing
|
||||
<!--
|
||||
[Please add testing done as part of this change.]
|
||||
-->
|
||||
<!-- Keep in mind that for backup-utils the following applies:
|
||||
- Backup-util [current version] will support
|
||||
- GHES [current version]
|
||||
- GHES [current version -1]
|
||||
- GHES [current version -2]
|
||||
- Any changes that are made to backup-utils will also need to be supported on those GHES versions above (n-2)
|
||||
- Please make sure those versions are tested against for this change
|
||||
-->
|
||||
|
||||
## Ownership
|
||||
<!-- [Add any relevants owners for this change]
|
||||
-->
|
||||
|
||||
## Related Links
|
||||
<!-- [Please add any related links/issues to this PR]
|
||||
-->
|
|
@ -1,118 +0,0 @@
|
|||
name: Backup GHES instance and save to Azure
|
||||
run-name: "${{ github.actor }} - Backup GHES instance and save to Azure"
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
github-hostname:
|
||||
description: GitHub Hostname to backup
|
||||
required: true
|
||||
type: string
|
||||
backup-name:
|
||||
description: The name of the backup to be saved in Azure storage
|
||||
required: false
|
||||
default: ""
|
||||
type: string
|
||||
secrets:
|
||||
BACKUP_SSH_KEY:
|
||||
description: SSH key to access the GitHub Enterprise instance
|
||||
required: true
|
||||
INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN:
|
||||
description: Token for the internal actions dx bot account
|
||||
required: true
|
||||
AZURE_USERNAME:
|
||||
description: Azure service principal username
|
||||
required: false
|
||||
AZURE_PASSWORD:
|
||||
description: Azure service principal password
|
||||
required: false
|
||||
AZURE_TENANT_ID:
|
||||
description: Azure tenant ID
|
||||
required: false
|
||||
AZURE_SUBSCRIPTION_ID:
|
||||
description: Azure subscription ID
|
||||
required: false
|
||||
AZURE_ACCOUNT_NAME:
|
||||
description: Azure storage account name
|
||||
required: false
|
||||
AZURE_CONTAINER_NAME:
|
||||
description: Azure storage container name
|
||||
required: false
|
||||
CONNECTIONSTRING:
|
||||
description: Azure storage connection string
|
||||
required: false
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: github/backup-utils-private
|
||||
token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}"
|
||||
- run: docker build . --file Dockerfile --tag backup-utils
|
||||
- run: docker save backup-utils -o backup-utils.tar
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: backup-utils
|
||||
path: backup-utils.tar
|
||||
|
||||
backup-utils-backup:
|
||||
needs: build
|
||||
runs-on:
|
||||
group: larger-hosted-public-runners
|
||||
labels: ubuntu-latest
|
||||
env:
|
||||
SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: backup-utils
|
||||
- name: Load docker container
|
||||
run: docker load -i backup-utils.tar
|
||||
- uses: actions/checkout@v4
|
||||
- name: Create backup directory
|
||||
run: mkdir "$HOME/ghe-backup-data"
|
||||
- name: set up ssh SSH_KEY
|
||||
run: echo -e "${SSH_KEY}\n" > "$HOME/backup"
|
||||
- name: set up ssh key permissions
|
||||
run: chmod 0600 "$HOME/backup"
|
||||
- name: change version
|
||||
run: echo "3.8.0" > "$HOME/version"
|
||||
|
||||
- name: Perform backup
|
||||
run: |
|
||||
docker run -e "GHE_HOSTNAME=${{ inputs.github-hostname }}" \
|
||||
-e "GHE_DATA_DIR=/data" \
|
||||
-e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \
|
||||
-e "GHE_NUM_SNAPSHOTS=15" \
|
||||
-v "$HOME/ghe-backup-data:/data" \
|
||||
-v "$HOME/backup:/ghe-ssh/id_rsa" \
|
||||
-v "$HOME/version:/backup-utils/share/github-backup-utils/version" \
|
||||
--rm \
|
||||
backup-utils ghe-backup
|
||||
- name: Check the backup file
|
||||
run: |
|
||||
current=$(readlink "$HOME/ghe-backup-data/current")
|
||||
sudo tar -czvf "${{ inputs.backup-name }}.tar.gz" -C "$HOME/ghe-backup-data/$current" .
|
||||
|
||||
- name: Login to Azure
|
||||
if: "${{ inputs.backup-name != '' }}"
|
||||
run: |
|
||||
az login \
|
||||
--service-principal \
|
||||
-u "${{ secrets.AZURE_USERNAME }}" \
|
||||
-p "${{ secrets.AZURE_PASSWORD }}" \
|
||||
--tenant "${{ secrets.AZURE_TENANT_ID }}"
|
||||
az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
|
||||
|
||||
- name: Upload backup to Azure
|
||||
if: "${{ inputs.backup-name != '' }}"
|
||||
run: |
|
||||
az storage blob upload \
|
||||
--account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \
|
||||
--container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \
|
||||
--name "${{ inputs.backup-name }}.tar.gz" \
|
||||
--file "${{ inputs.backup-name }}.tar.gz" \
|
||||
--connection-string "${{ secrets.CONNECTIONSTRING }}"
|
|
@ -1,87 +0,0 @@
|
|||
name: Backup and Restore
|
||||
run-name: ${{ github.actor }} running backup and restore operation
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
hostname:
|
||||
description: 'Hostname'
|
||||
required: true
|
||||
type: string
|
||||
ref:
|
||||
description: 'Ref'
|
||||
required: false
|
||||
type: string
|
||||
default: 'master'
|
||||
workflow_call:
|
||||
inputs:
|
||||
hostname:
|
||||
description: 'Hostname'
|
||||
required: true
|
||||
type: string
|
||||
ref:
|
||||
description: 'Ref'
|
||||
required: false
|
||||
type: string
|
||||
default: 'master'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: github/backup-utils-private
|
||||
ref: ${{ inputs.ref }}
|
||||
- run: docker build . --file Dockerfile --tag backup-utils
|
||||
- run: docker save backup-utils -o backup-utils.tar
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: backup-utils
|
||||
path: backup-utils.tar
|
||||
backup-utils-backup-and-restore:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: backup-utils
|
||||
- name: Load docker container
|
||||
run: docker load -i backup-utils.tar
|
||||
- uses: actions/checkout@v4
|
||||
- name: Create backup directory
|
||||
run: mkdir "$HOME"/ghe-backup-data
|
||||
- name: set up ssh SSH_KEY
|
||||
run: echo -e "${SSH_KEY}\n" > "$HOME"/backup
|
||||
- name: set up ssh key permissions
|
||||
run: chmod 0600 "$HOME"/backup
|
||||
- name: change version
|
||||
run: echo "3.8.0" > "$HOME"/version
|
||||
- name: Perform backup
|
||||
run: |
|
||||
docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \
|
||||
-e "GHE_DATA_DIR=/data" \
|
||||
-e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \
|
||||
-e "GHE_NUM_SNAPSHOTS=15" \
|
||||
-v "$HOME/ghe-backup-data:/data" \
|
||||
-v "$HOME/backup:/ghe-ssh/id_rsa" \
|
||||
-v "$HOME/version:/backup-utils/share/github-backup-utils/version" \
|
||||
--rm \
|
||||
backup-utils ghe-backup
|
||||
- name: Prepare for restore
|
||||
run: ssh -p122 -i "$HOME"/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s"
|
||||
- name: Restore data to instance
|
||||
run: |
|
||||
docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \
|
||||
-e "GHE_DATA_DIR=/data" \
|
||||
-e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \
|
||||
-e "GHE_NUM_SNAPSHOTS=15" \
|
||||
-v "$HOME/ghe-backup-data:/data" \
|
||||
-v "$HOME/backup:/ghe-ssh/id_rsa" \
|
||||
-v "$HOME/version:/backup-utils/share/github-backup-utils/version" \
|
||||
--rm \
|
||||
backup-utils ghe-restore ${{ inputs.hostname }}
|
||||
- name: Reset maintenance mode after restore
|
||||
run: ssh -p122 -i "$HOME"/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u"
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
---
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version - patch version of the release (e.g. x.y.z)'
|
||||
required: true
|
||||
type: string
|
||||
draft:
|
||||
description: 'Draft - true if the release should be a draft'
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
rc-app-token: ${{ steps.app-token.outputs.token }}
|
||||
steps:
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }}
|
||||
private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repositories: "backup-utils-private"
|
||||
- name: Checkout backup-utils-private
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y moreutils debhelper help2man devscripts gzip
|
||||
- name: Create tag # this is required for the build scripts
|
||||
run: |
|
||||
git config user.name "${{ github.actor }}"
|
||||
git config user.email "ghes-releases-team@github.com"
|
||||
git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}"
|
||||
git push origin "v${{ github.event.inputs.version }}"
|
||||
- name: Package deb
|
||||
run: |
|
||||
./script/package-deb
|
||||
- name: Upload deb artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: github-backup-utils_${{ github.event.inputs.version }}_all.deb
|
||||
path: |
|
||||
dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb
|
||||
- name: Package tarball
|
||||
run: |
|
||||
./script/package-tarball
|
||||
- name: Upload tarball artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz
|
||||
path: |
|
||||
dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz
|
||||
release:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
commit_hash: ${{ steps.empty-commit.outputs.commit_hash }}
|
||||
steps:
|
||||
- uses: actions/create-github-app-token@v1
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }}
|
||||
private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
repositories: "backup-utils,backup-utils-private"
|
||||
- name: Get major-feature from version
|
||||
id: get-major-feature
|
||||
run: |
|
||||
echo "MAJOR_FEATURE=$(echo ${{ github.event.inputs.version }} | cut -d '.' -f 1,2)" >> "$GITHUB_ENV"
|
||||
- name: Verify major-feature
|
||||
run: |
|
||||
echo "major_feature: $MAJOR_FEATURE"
|
||||
- name: Checkout backup-utils
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
repository: github/backup-utils
|
||||
- name: Create empty commit
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
id: empty-commit
|
||||
with:
|
||||
branch: ${{ env.MAJOR_FEATURE }}-stable
|
||||
commit_message: "${{ github.event.inputs.version }} release"
|
||||
commit_user_name: "release-controller[bot]"
|
||||
commit_user_email: "223695+release-controller[bot]@users.noreply.github.com"
|
||||
commit_options: "--allow-empty"
|
||||
push_options: "--force"
|
||||
skip_dirty_check: true
|
||||
- name: Checkout backup-utils-private for release notes
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
repository: github/backup-utils-private
|
||||
- name: Download deb artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: github-backup-utils_${{ github.event.inputs.version }}_all.deb
|
||||
- name: Download tarball artifact
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz
|
||||
- name: Create Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
owner: github
|
||||
repo: backup-utils
|
||||
name: |
|
||||
GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }}
|
||||
artifacts: |
|
||||
github-backup-utils-v${{ github.event.inputs.version }}.tar.gz,
|
||||
github-backup-utils_${{ github.event.inputs.version }}_all.deb
|
||||
tag: v${{ github.event.inputs.version }}
|
||||
commit: ${{ env.MAJOR_FEATURE }}-stable
|
||||
bodyFile: release-notes/${{ github.event.inputs.version }}.md
|
||||
draft: ${{ github.event.inputs.draft }}
|
||||
allowUpdates: true
|
||||
artifactContentType: "raw"
|
|
@ -1,21 +0,0 @@
|
|||
---
|
||||
name: Auto Close Pull Requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 * * * *'
|
||||
|
||||
jobs:
|
||||
close-fork-pulls:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Close Pull Requests
|
||||
uses: peter-evans/close-fork-pulls@v2
|
||||
with:
|
||||
comment: |
|
||||
As of 2023-11-30 we have stopped the 2-way sync between this repository and our internal repository, so that our internal repository becomes the source of truth for the backup-utils source code. With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository.
|
||||
|
||||
Customers should no longer open pull requests in this repository. These pull requests will not be reviewed or merged. We will automatically close all PRs opened in this repository.
|
||||
|
||||
Customers cannot open issues in this repository. Instead, customers will need to follow the standard support process and open a support ticket for any questions/concerns/problems with backup-utils. This will ensure all customer requests are handled consistently.
|
|
@ -1,28 +0,0 @@
|
|||
name: Docker Image Build CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
jobs:
|
||||
|
||||
build-docker:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Build the Ubuntu Docker image
|
||||
run: docker build . --file Dockerfile --tag backup-utils:"${GITHUB_RUN_ID}"
|
||||
- name: Build the Alpine Docker image
|
||||
run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:"${GITHUB_RUN_ID}"
|
||||
- name: Run tests in Ubuntu Docker image
|
||||
run: |
|
||||
docker run backup-utils:"${GITHUB_RUN_ID}" ghe-backup --version
|
||||
docker run backup-utils:"${GITHUB_RUN_ID}" rsync --version
|
||||
- name: Run tests in Alpine Docker image
|
||||
run: |
|
||||
docker run backup-utils-alpine:"${GITHUB_RUN_ID}" ghe-backup --version
|
||||
docker run backup-utils-alpine:"${GITHUB_RUN_ID}" rsync --version
|
|
@ -1,69 +0,0 @@
|
|||
name: Run Integration Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
branches: ['master', 'enterprise-[0-9]*.[0-9]*-release', 'enterprise-[0-9]*.[0-9]*.[0-9]*-release']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
target-branch:
|
||||
description: 'enterprise2 branch to test against'
|
||||
required: true
|
||||
source-branch:
|
||||
description: 'backup-utils-private topic branch to test'
|
||||
required: true
|
||||
|
||||
# Get target and source branch from different variables depending on how it was triggered
|
||||
env:
|
||||
TARGET_BRANCH: '${{ github.event.inputs.target-branch || github.base_ref }}'
|
||||
SOURCE_BRANCH: '${{ github.event.inputs.source-branch || github.head_ref }}'
|
||||
|
||||
jobs:
|
||||
integration-tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
jankyJobName:
|
||||
- enterprise2-backup-utils-binary-backup
|
||||
- enterprise2-backup-utils-migration
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Queue ${{ matrix.jankyJobName }} build
|
||||
uses: ./.github/actions/proxy-janky-build
|
||||
id: proxy-janky-build
|
||||
with:
|
||||
janky-token: '${{ secrets.API_AUTH_TOKEN }}'
|
||||
job-name: '${{ matrix.jankyJobName }}'
|
||||
branch-name: '${{ env.SOURCE_BRANCH }}'
|
||||
force : 'false'
|
||||
# enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release)
|
||||
envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}"
|
||||
|
||||
# Cluster integration tests are optional based on label and PR titles
|
||||
cluster-integration-tests:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
jankyJobName:
|
||||
- enterprise2-backup-utils-cluster-binary-backup
|
||||
- enterprise2-backup-utils-cluster-migration
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Queue ${{ matrix.jankyJobName }} build
|
||||
if: |
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
contains(github.event.pull_request.title, '[cluster]') ||
|
||||
contains(github.event.pull_request.labels.*.name, 'cluster')
|
||||
uses: ./.github/actions/proxy-janky-build
|
||||
id: proxy-janky-build
|
||||
with:
|
||||
janky-token: '${{ secrets.API_AUTH_TOKEN }}'
|
||||
job-name: '${{ matrix.jankyJobName }}'
|
||||
branch-name: '${{ env.SOURCE_BRANCH }}'
|
||||
force : 'false'
|
||||
# enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release)
|
||||
envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}"
|
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
name: Lint Code Base
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint Code Base
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
- name: Lint Code Base
|
||||
uses: super-linter/super-linter@v5
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
BASH_SEVERITY: error
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
FILTER_REGEX_EXCLUDE: .*release-notes/.*
|
|
@ -1,28 +0,0 @@
|
|||
name: Test and build
|
||||
|
||||
on: [pull_request, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['ubuntu-22.04', 'ubuntu-20.04']
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Install Dependencies (Linux)
|
||||
run: |
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man
|
||||
wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz"
|
||||
tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz"
|
||||
sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck
|
||||
- name: Get Sources
|
||||
uses: actions/checkout@v4
|
||||
- name: Test
|
||||
run: |
|
||||
export PATH="$PATH:/snap/bin"
|
||||
make test
|
||||
shell: bash
|
||||
- name: Build (Linux)
|
||||
run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc
|
|
@ -1,152 +0,0 @@
|
|||
name: Restore Dataset
|
||||
run-name: ${{ github.actor }} retrieving data-sets
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
size:
|
||||
description: 'Size of the dataset to restore'
|
||||
required: true
|
||||
type: choice
|
||||
options:
|
||||
- 'small'
|
||||
- 'medium'
|
||||
hostname:
|
||||
description: 'Hostname of the server'
|
||||
required: true
|
||||
type: string
|
||||
ref:
|
||||
description: 'Branch ref to use'
|
||||
required: false
|
||||
type: string
|
||||
default: 'master'
|
||||
version:
|
||||
description: 'Version of the dataset to restore (3.8/3.9)'
|
||||
required: false
|
||||
default: '3.8'
|
||||
type: string
|
||||
|
||||
workflow_call:
|
||||
inputs:
|
||||
hostname:
|
||||
description: 'Hostname of the server'
|
||||
required: true
|
||||
type: string
|
||||
size:
|
||||
description: 'Size of the dataset to restore (small/medium)'
|
||||
required: false
|
||||
default: 'small'
|
||||
type: string
|
||||
version:
|
||||
description: 'Version of the dataset to restore (3.8/3.9)'
|
||||
required: false
|
||||
default: '3.8'
|
||||
type: string
|
||||
ref:
|
||||
description: 'Branch ref to use'
|
||||
required: false
|
||||
type: string
|
||||
default: 'master'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
repository: github/backup-utils-private
|
||||
ref: ${{ inputs.ref }}
|
||||
token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}"
|
||||
|
||||
- run: docker build . --file Dockerfile --tag backup-utils
|
||||
- run: docker save backup-utils -o backup-utils.tar
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: backup-utils
|
||||
path: backup-utils.tar
|
||||
|
||||
restore:
|
||||
needs: build
|
||||
runs-on:
|
||||
group: larger-hosted-public-runners
|
||||
labels: ubuntu-latest
|
||||
env:
|
||||
SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }}
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: backup-utils
|
||||
|
||||
- name: Load docker container
|
||||
run: docker load -i backup-utils.tar
|
||||
|
||||
- name: Find backup file version
|
||||
id: file
|
||||
run: |
|
||||
version="${{ inputs.version }}"
|
||||
size="${{ inputs.size }}"
|
||||
V3_6_COMPATIBLE="3.6 3.7"
|
||||
V3_8_COMPATIBLE="3.8 3.9 3.10"
|
||||
if echo "$V3_8_COMPATIBLE" | grep -q -w "$version"; then
|
||||
echo "Version $version is acceptable by 3.8 backup"
|
||||
file_version=3.8
|
||||
elif echo "$V3_6_COMPATIBLE" | grep -q -w "$version"; then
|
||||
echo "Version $version is acceptable by 3.6 backup"
|
||||
file_version=3.6
|
||||
else
|
||||
echo "Version $version is not acceptable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "version=$file_version" >> "$GITHUB_OUTPUT"
|
||||
echo "name=v$file_version-$size.tar.gz" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Download from blob storage
|
||||
run: |
|
||||
mkdir ghes-data
|
||||
az storage blob download \
|
||||
--account-name ghesresults \
|
||||
--container-name ghes-data \
|
||||
--name "${{ steps.file.outputs.name }}" \
|
||||
--file "ghes-data/${{ steps.file.outputs.name }}" \
|
||||
--connection-string "${{ secrets.CONNECTIONSTRING }}"
|
||||
|
||||
- name: Unzip backup and setup symlink
|
||||
run: |
|
||||
mkdir "$HOME/ghe-backup-data"
|
||||
dir_name=$(date +%s)
|
||||
mkdir "$HOME/ghe-backup-data/$dir_name"
|
||||
|
||||
tar -xvf "ghes-data/${{ steps.file.outputs.name }}" -C "$HOME/ghe-backup-data/$dir_name"
|
||||
|
||||
ln -s "$dir_name" "$HOME/ghe-backup-data/current"
|
||||
|
||||
- name: set up ssh SSH_KEY
|
||||
run: echo -e "${SSH_KEY}\n" > "$HOME/backup"
|
||||
|
||||
- name: set up ssh key permissions
|
||||
run: chmod 0600 "$HOME/backup"
|
||||
|
||||
- name: change version
|
||||
run: echo "${{ inputs.version }}.0" > "$HOME/version"
|
||||
|
||||
- name: Prepare for restore
|
||||
run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s"
|
||||
|
||||
- name: Restore data to instance
|
||||
run: |
|
||||
docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \
|
||||
-e "GHE_DATA_DIR=/data" \
|
||||
-e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \
|
||||
-e "GHE_NUM_SNAPSHOTS=15" \
|
||||
-v "$HOME/ghe-backup-data:/data" \
|
||||
-v "$HOME/backup:/ghe-ssh/id_rsa" \
|
||||
-v "$HOME/version:/backup-utils/share/github-backup-utils/version" \
|
||||
--rm \
|
||||
backup-utils ghe-restore ${{ inputs.hostname }}
|
||||
|
||||
- name: Reset maintenance mode after restore
|
||||
run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u"
|
||||
|
||||
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
name: Update Rsync Tag in Dockerfile
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '0 0 * * *' # Runs daily at 00:00
|
||||
|
||||
jobs:
|
||||
update-rsync-tag:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get latest rsync tag
|
||||
id: latest_tag
|
||||
run: curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Update Dockerfile with latest tag
|
||||
run: |
|
||||
sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile
|
||||
|
||||
- name: Create Pull Request for tag update
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: "Update rsync tag in Dockerfile"
|
||||
title: "Update rsync tag in Dockerfile"
|
||||
body: "This PR updates the rsync tag in the Dockerfile to the latest tagged version."
|
||||
branch: "update-rsync-tag"
|
||||
base: "master"
|
||||
add-paths: "Dockerfile"
|
||||
labels: "automated-update,rsync"
|
|
@ -1,6 +0,0 @@
|
|||
/backup.config
|
||||
/data
|
||||
/dist
|
||||
.DS_Store
|
||||
dash
|
||||
parallel
|
|
@ -1,2 +0,0 @@
|
|||
ownership.yaml
|
||||
.github
|
|
@ -1 +0,0 @@
|
|||
2.4.0
|
Загрузка…
Ссылка в новой задаче