Inital Release

This commit is contained in:
Jyotirmoy Bandyopadhayaya 2022-09-17 11:32:38 +05:30
commit 92eb8ce651
Signed by: bravo68web
GPG Key ID: F5671FD7BCB9917A
7 changed files with 107 additions and 0 deletions

31
.github/workflows/gitea.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Test on Gitea
on:
delete:
push:
pull_request:
jobs:
check_preconditions:
runs-on: ubuntu-latest
outputs:
results: ${{ join(steps.*.outcome) }}
steps:
- id: secrets
continue-on-error: true
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
TARGET_REPO_URL: ${{ secrets.TARGET_GITEA_REPO_URL }}
run: '[ -n "$SSH_PRIVATE_KEY" ] && [ -n "$TARGET_REPO_URL" ]'
mirroring:
needs: check_preconditions
if: "!contains(needs.check_preconditions.outputs.results, 'failure')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./
with:
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
target_repo_url: ${{ secrets.TARGET_REPO_URL }}

30
.github/workflows/gitlab.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: Test on Gitlab
on:
delete:
push:
pull_request:
jobs:
check_preconditions:
runs-on: ubuntu-latest
outputs:
results: ${{ join(steps.*.outcome) }}
steps:
- id: secrets
continue-on-error: true
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
TARGET_REPO_URL: ${{ secrets.TARGET_GITLAB_REPO_URL }}
run: '[ -n "$SSH_PRIVATE_KEY" ] && [ -n "$TARGET_REPO_URL" ]'
mirroring:
needs: check_preconditions
if: "!contains(needs.check_preconditions.outputs.results, 'failure')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: ./
with:
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
target_repo_url: ${{ secrets.TARGET_GITLAB_REPO_URL }}

11
Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM alpine
RUN apk update && apk upgrade && \
apk add --no-cache git openssh git-lfs
RUN git lfs install
COPY mirror.sh /mirror.sh
COPY setup-ssh.sh /setup-ssh.sh
ENTRYPOINT ["/mirror.sh"]

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# Git Sync Mirror

19
action.yml Normal file
View File

@ -0,0 +1,19 @@
name: "Git Sync Mirror"
description: "Mirror your repository into another repository (Gitea and GitLab)"
branding:
icon: "copy"
color: "yellow"
inputs:
ssh_private_key:
description: "SSH private key for ssh connection to the target repository"
required: false
target_repo_url:
description: "Target url"
required: true
ssh_username:
description: "Username for ssh connection"
required: false
default: "git"
runs:
using: 'docker'
image: 'Dockerfile'

8
mirror.sh Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -eu
/setup.sh
export GIT_SSH_COMMAND="ssh -v -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no -l $INPUT_SSH_USERNAME"
git remote add mirror "$INPUT_TARGET_REPO_URL"
git push --tags --force --prune mirror "refs/remotes/origin/*:refs/heads/*"

6
setup.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env sh
set -eu
mkdir -p ~/.ssh
echo "$INPUT_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa