aboutsummaryrefslogtreecommitdiff
path: root/mirror-to-github
diff options
context:
space:
mode:
authorJulien Dessaux2022-09-08 19:59:40 +0200
committerJulien Dessaux2022-09-08 19:59:40 +0200
commitd49bcbec73654fa6018274e9daf1314375b08363 (patch)
treeb0a6bd3617f53485a7df7f3cb72b744eeed19ec7 /mirror-to-github
parentMoved away from job parameters to command arguments (diff)
downloadev-scripts-d49bcbec73654fa6018274e9daf1314375b08363.tar.gz
ev-scripts-d49bcbec73654fa6018274e9daf1314375b08363.tar.bz2
ev-scripts-d49bcbec73654fa6018274e9daf1314375b08363.zip
Added mirror to github script and job
Diffstat (limited to 'mirror-to-github')
-rw-r--r--mirror-to-github/mirror-to-github.sh17
-rw-r--r--mirror-to-github/mirror-to-github.yaml12
2 files changed, 29 insertions, 0 deletions
diff --git a/mirror-to-github/mirror-to-github.sh b/mirror-to-github/mirror-to-github.sh
new file mode 100644
index 0000000..f831f0c
--- /dev/null
+++ b/mirror-to-github/mirror-to-github.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Input environment:
+# - REPO: The repository path part of the url to mirror, for example: adyxax/www
+# Requires a github identity!
+
+WORKDIR="/tmp/$(basename ${REPO})"
+
+cleanup() {
+ rm -rf "${WORKDIR}"
+}
+
+trap cleanup EXIT
+
+git clone -q "https://git.adyxax.org/${REPO}" "${WORKDIR}"
+(cd ${WORKDIR}; git remote add github https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${REPO}; git push github --mirror)
diff --git a/mirror-to-github/mirror-to-github.yaml b/mirror-to-github/mirror-to-github.yaml
new file mode 100644
index 0000000..d84ed98
--- /dev/null
+++ b/mirror-to-github/mirror-to-github.yaml
@@ -0,0 +1,12 @@
+name: "mirror-to-github"
+steps:
+ - label: mirror
+ script:
+ path: "mirror-to-github.sh"
+identities:
+ - github-mirror
+parameters:
+- name: repo
+ type: string
+ environment: REPO
+ default: "adyxax/non-existent"