~tcarrio/git-mirror

4e9027de3f1455a45298cd2ea8f4b8d208b0cbd5 — Tom Carrio 3 years ago 1d944b4
Updated secret and SSH key path to the default id_rsa
3 files changed, 5 insertions(+), 5 deletions(-)

M .build.yml
M README.md
M git-mirror.sh
M .build.yml => .build.yml +1 -1
@@ 9,7 9,7 @@ environment:
  HELPERS_DIR: build-helpers
  GIT_TARGET_REPO: git@github.com:tcarrio/github-mirror.git
secrets:
  - 1228fb70-1962-40d9-b1c8-941e56c6a8a1
  - 4e983fc2-9d24-43eb-9986-1c18feb2e7b8
tasks:
  - mirror-any: |
      git-mirror/git-mirror.sh $PROJECT_DIR

M README.md => README.md +3 -3
@@ 9,15 9,15 @@ This solution is meant to tie in easily with the build tools provided by SourceH
## Getting Started

1. Generate an SSH token and add it to your GitHub account
2. Generate a file secret on https://builds.sr.ht/secrets to load at `~/git_ssh_token`
2. Generate a file secret on https://builds.sr.ht/secrets to load at `~/.ssh/id_rsa`
3. Update your `.builds.yml` pipeline with the following:
  - Include the secret reference under the `secrets`
  - Include this repository under the `sources`
  - Include the `build` stage of the example pipeline in your pipeline
  - Include the target repository as the environment variable `GIT_TARGET_URL`
  - Include the target repository as the environment variable `$GIT_TARGET_URL`

## What's happening

Repositories listed under `sources` are cloned to the current working directory, so you will have directories per repo that you can reference using `./repo-name`. This repository includes a simple shell script that will use your SSH token at `~/git_ssh_token` to push your current branch to the target git repository's branch. Simple stuff.
Repositories listed under `sources` are cloned to the current working directory, so you will have directories per repo that you can reference using `./repo-name`. This repository includes a simple shell script that will use your SSH token at `~/.ssh/id_rsa` to push your current branch to the target git repository's branch. Simple stuff.

**Warning:** This forces the push, taking into consideration that the target should be a downstream mirror, it will overwrite the state there should it have a diverged git history from your SourceHut repo.
\ No newline at end of file

M git-mirror.sh => git-mirror.sh +1 -1
@@ 1,6 1,6 @@
#!/usr/bin/env sh

export SSH_TOKEN_PATH=${SSH_TOKEN_PATH:-~/.ssh/git_ssh_token}
export SSH_TOKEN_PATH=${SSH_TOKEN_PATH:-~/.ssh/id_rsa}
export GIT_LOCAL_REPO=${1:-${PWD}}
export GIT_TARGET_REPO=${GIT_TARGET_REPO}
export GIT_TARGET_REMOTE=downstream