diff --git a/.tangled/workflows/mirror.yaml b/.tangled/workflows/mirror.yaml index f9002e3..e558675 100644 --- a/.tangled/workflows/mirror.yaml +++ b/.tangled/workflows/mirror.yaml @@ -8,6 +8,9 @@ when: engine: "nixery" +dependencies: + nixpkgs: + - openssh steps: # spindle clones one commit deep (depth: 0 means 1 too), and the mirrors # need the whole history. this also points origin/main at the newest main, @@ -22,7 +25,20 @@ steps: set -euo pipefail git push --force "https://x-access-token:${GH_MIRROR_TOKEN}@github.com/daniel-daum/dotfiles.git" refs/remotes/origin/main:refs/heads/main + # over ssh to git-ssh, which skips cloudflare. https to git.danieldaum.net + # goes through it, and its bot protection blocks spindle at random - name: "Mirror to Gitea" command: | - set -euo pipefail - git push --force "https://daniel-daum:${GITEA_MIRROR_TOKEN}@git.danieldaum.net/daniel-daum/dotfiles.git" refs/remotes/origin/main:refs/heads/main + set -euo pipefail + + # ssh refuses to run without a passwd entry, and nixery images have none + mkdir -p /etc + [ -e /etc/passwd ] || echo "root:x:0:0:root:${HOME}:/bin/bash" > /etc/passwd + + mkdir -p "${HOME}/.ssh" + printf '%s\n' "${GITEA_MIRROR_KEY}" > "${HOME}/.ssh/gitea" + chmod 600 "${HOME}/.ssh/gitea" + ssh-keyscan -p 2222 git-ssh.danieldaum.net > "${HOME}/.ssh/known_hosts" + + export GIT_SSH_COMMAND="ssh -i ${HOME}/.ssh/gitea -o IdentitiesOnly=yes -o UserKnownHostsFile=${HOME}/.ssh/known_hosts" + git push --force "ssh://git@git-ssh.danieldaum.net:2222/daniel-daum/${TANGLED_REPO_NAME}.git" refs/remotes/origin/main:refs/heads/main