Skip to content

Repo Sync

Repo Sync #110486

Workflow file for this run

name: Repo Sync
on:
schedule:
- cron: "2/13 * * * *"
repository_dispatch:
types: sync-repo
watch:
types: [started]
jobs:
repo-sync:
name: Repo Sync
runs-on: ubuntu-latest
env:
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa"
steps:
- uses: actions/checkout@v2
- name: setup ssh key
run: |
mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo $HOME
echo $GITHUB_WORKSPACE
shell: bash
env:
SSH_KEY: ${{secrets.SSH_PRIVATE_KEY}}
- name: Get current time
uses: gerred/actions/current-time@master
id: current-time
- name: Cache Origional files
id: cache
uses: actions/cache@v2
with:
path: |
~/work/the_repo
key: I am a key!
- name: Clone from target repo
if: steps.cache.outputs.cache-hit != 'true'
run: |
git clone --mirror git@github.com:KusakabeSi/dn42-registry.git ~/work/the_repo
- name: Pull from source repo
run: |
cd ~/work/the_repo
set -x
if git remote add source https://${{secrets.DN42_GIT_TOKEN}}@git.dn42.dev/dn42/registry.git ; then
echo "add"
else
git remote set-url source https://${{secrets.DN42_GIT_TOKEN}}@git.dn42.dev/dn42/registry.git
echo "set"
fi
git fetch source '+refs/heads/*:refs/heads/*' '+refs/tags/*:refs/tags/*'
shell: bash
- name: Add remote gitlab
run: |
cd ~/work/the_repo
set -x
if git remote add gitlab git@gitlab.com:kskbsi/data/dn42-registry.git ; then
echo "add gitlab"
fi
shell: bash
- name: Push back to target repo
run: |
cd ~/work/the_repo
git push -f --mirror origin
git push -f --mirror gitlab
shell: bash
- name: wrtie something to prevent this action inactive
run: |
echo $(date +%Y-%m-%d) > $GITHUB_WORKSPACE/sync
shell: bash
- name: Commit & Push changes
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
force: true
author_email: si@kskb.eu.org
author_name: KusakabeSi
message: sync at ${{ steps.current-time.outputs.time }}