1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-06 01:20:24 +08:00

TUN-9800: Add pipeline to sync between gitlab and github repos

This commit is contained in:
João "Pisco" Fernandes
2025-09-22 15:44:50 +01:00
parent 80b1634515
commit 71448c1f7f
3 changed files with 54 additions and 1 deletions

31
.ci/scripts/github-push.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -e -o pipefail
BRANCH="master"
TMP_PATH="$PWD/tmp"
PRIVATE_KEY_PATH="$TMP_PATH/github-deploy-key"
PUBLIC_KEY_GITHUB_PATH="$TMP_PATH/github.pub"
mkdir -p $TMP_PATH
# Setup Private Key
echo "$CLOUDFLARED_DEPLOY_SSH_KEY" > $PRIVATE_KEY_PATH
chmod 400 $PRIVATE_KEY_PATH
# Download GitHub Public Key for KnownHostsFile
ssh-keyscan -t ed25519 github.com > $PUBLIC_KEY_GITHUB_PATH
# Setup git ssh command with the right configurations
export GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=$PUBLIC_KEY_GITHUB_PATH -o IdentitiesOnly=yes -i $PRIVATE_KEY_PATH"
# Add GitHub as a new remote
git remote add github git@github.com:cloudflare/cloudflared.git || true
# GitLab doesn't pull branch references, instead it creates a new one on each pipeline.
# Therefore, we need to manually fetch the reference to then push it to GitHub.
git fetch origin $BRANCH:$BRANCH
git push -u github $BRANCH
if TAG="$(git describe --tags --exact-match 2>/dev/null)"; then
git push -u github "$TAG"
fi