From a9e304617befb140872e046ef1cc20c732e9728a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Mon, 14 Jun 2021 23:28:23 +0000 Subject: [PATCH] feat/upstreaming (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Benjamin Bädorf Co-authored-by: teutat3s Reviewed-on: https://git.b12f.io/pub-solar/os/pulls/4 Co-authored-by: Benjamin Bädorf Co-committed-by: Benjamin Bädorf --- .drone.yml | 96 ++++++++++++++++++++++++----- .drone/setup_ssh.sh | 11 ++++ .drone/upstream-branch.sh | 12 ++++ hosts/{NixOS.nix => PubSolarOS.nix} | 0 4 files changed, 105 insertions(+), 14 deletions(-) create mode 100755 .drone/setup_ssh.sh create mode 100755 .drone/upstream-branch.sh rename hosts/{NixOS.nix => PubSolarOS.nix} (100%) diff --git a/.drone.yml b/.drone.yml index e68250e..4b797f7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,23 +1,91 @@ +--- kind: pipeline type: docker -name: api +name: Upstreaming steps: - - name: "Sync upstream and try PR" - image: docker.b12f.io/pub-solar/minimal-git:latest - settings: - registry: docker.b12f.io - repo: docker.b12f.io/pub-solar/minimal-git - username: - from_secret: docker_username - password: - from_secret: docker_password + - name: "Sync upstream to local" + image: alpine/git + when: + event: + - cron + - promote + target: + - upstream + branch: + - core environment: GITEA_SSH_KEY: from_secret: gitea_ssh_key commands: - - echo $GITEA_SSH_KEY > ~/.ssh/id_rsa - - git clone -b core git@git.b12f.io:pub-solar/os - - git remote add devos https://github.com/divnix/devos.git + - ./.drone/setup_ssh.sh + - git fetch + - git checkout devos + - git remote add devos git@git.b12f.io:pub-solar/devos + - git remote set-url origin git@git.b12f.io:pub-solar/os - git fetch --all - - git rebase devos/core + - git merge -X theirs devos/core + - git push origin devos + + - name: "Sync branch with upstream" + image: alpine/git + when: + status: + - success + event: + - cron + - promote + target: + - upstream + environment: + GITEA_SSH_KEY: + from_secret: gitea_ssh_key + commands: + - ./.drone/setup_ssh.sh + - git remote set-url origin git@git.b12f.io:pub-solar/os + - ./.drone/upstream-branch.sh + + - name: "Open pull request for failed merge" + image: nixery.dev/shell/tea + when: + status: + - failure + event: + - cron + - promote + target: + - upstream + branch: + - core + environment: + TEA_CONFIG: + from_secret: tea_config + commands: + - mkdir -p ~/.config/tea + - echo "$$TEA_CONFIG" > ~/.config/tea/config.yml + - tea pulls create --base core --head devos + + - name: "Notify matrix" + image: plugins/matrix + when: + status: + - success + - failure + event: + - cron + - promote + target: + - upstream + settings: + homeserver: https://matrix.pub.solar + roomid: dfQBqwkhIzrFjMSsxy:pub.solar + username: + from_secret: matrix_username + password: + from_secret: matrix_password + template: "Upstreaming {{ build.status }} [{{ build.branch }}#{{ truncate build.commit 8 }}]({{ build.link }}) by {{ build.author }}. [Pull requests](https://git.b12f.io/pub-solar/os/pulls)" +--- +kind: signature +hmac: b7ad6e3b722b175ffdffd610784fbaf8d675278a64c7e3c62dc5a05b8ae3e2ad + +... diff --git a/.drone/setup_ssh.sh b/.drone/setup_ssh.sh new file mode 100755 index 0000000..f4a1bbd --- /dev/null +++ b/.drone/setup_ssh.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +set -e + +# Setup ssh inside container +mkdir -p ~/.ssh +echo "$GITEA_SSH_KEY" > ~/.ssh/id_rsa +echo "[git.b12f.io]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ4uaREL7acSSCNAX+voDYl1Kj7JipP62fR5x1UyGP9u" >> ~/.ssh/known_hosts +echo "Host git.b12f.io" >> ~/.ssh/config +echo " Port 2222" >> ~/.ssh/config +chmod -R 600 ~/.ssh diff --git a/.drone/upstream-branch.sh b/.drone/upstream-branch.sh new file mode 100755 index 0000000..cda8133 --- /dev/null +++ b/.drone/upstream-branch.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env sh + +set -e +set -u + +LOCAL="$DRONE_BRANCH" +[ "$LOCAL" = "core" ] && UPSTREAM=origin/devos || UPSTREAM=origin/core + +git fetch --all +git checkout "$LOCAL" +git merge "$UPSTREAM" +git push origin "$LOCAL" diff --git a/hosts/NixOS.nix b/hosts/PubSolarOS.nix similarity index 100% rename from hosts/NixOS.nix rename to hosts/PubSolarOS.nix