GitHub Action for backup your git repository.
- Generate deploy key
ssh-keygen -t rsa -f git-backup -q -N ""
- Then go to "Settings > Deploy Keys" of the target repository
- Add your public key within "Allow write access" option.
- Copy your private deploy key to
GIT_DEPLOY_KEY
secret in your source git repository of "Settings > Secrets"
GIT_DEPLOY_KEY
: Required, your deploy key (ssh private key) which has Write accessTARGET_GIT
: required, your backup git repository (please use ssh or git protocol)BRANCH
: optional, the branch you want to backup (default value ismaster
)
name: Backup Git Repository
on:
push:
branches:
- master
jobs:
git-repo-backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: git-repo-backup
uses: jenkins-zh/[email protected]
env:
GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }}
TARGET_GIT: "[email protected]:surenpi/surenpi.git"
BRANCH: master