From 8345f3a6f48317b7dfaad46a6f798e339fc41483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Tue, 15 Jun 2021 01:21:08 +0200 Subject: [PATCH] No idea what I did or whether it works --- .drone.yml | 51 +++++++++------------------------------ .drone/setup_ssh.sh | 5 +++- .drone/upstream-branch.sh | 12 +++++++++ 3 files changed, 27 insertions(+), 41 deletions(-) create mode 100644 .drone/upstream-branch.sh diff --git a/.drone.yml b/.drone.yml index d9e572be..80e370bd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,6 +1,6 @@ kind: pipeline type: docker -name: upstreaming +name: Upstreaming steps: - name: "Sync upstream to local" @@ -11,11 +11,13 @@ steps: - promote target: - upstream + branch: + - core environment: GITEA_SSH_KEY: from_secret: gitea_ssh_key commands: - - sh .drone/setup_ssh.sh + - ./.drone/setup_ssh.sh - git fetch - git checkout devos - git remote add devos git@git.b12f.io:pub-solar/devos @@ -24,7 +26,7 @@ steps: - git merge -X theirs devos/core - git push origin devos - - name: "Sync core with upstream" + - name: "Sync branch with upstream" image: alpine/git when: status: @@ -34,39 +36,12 @@ steps: - promote target: - upstream - depends_on: - - "Sync upstream to local" environment: GITEA_SSH_KEY: from_secret: gitea_ssh_key commands: - - git checkout feat/upstreaming - - sh .drone/setup_ssh.sh - - git fetch --all - - git checkout --track origin/core - - git merge origin/devos - - git push origin core - - - name: "Notify success" - image: plugins/matrix - when: - status: - - success - event: - - cron - - promote - target: - - upstream - depends_on: - - "Sync core with upstream" - settings: - homeserver: https://matrix.pub.solar - roomid: dfQBqwkhIzrFjMSsxy:pub.solar - username: - from_secret: matrix_username - password: - from_secret: matrix_password - template: Upstreaming devos into core succeeded. + - ./.drone/setup_ssh.sh + - ./.drone/upstream-branch.sh - name: "Open pull request for failed merge" image: nixery.dev/shell/tea @@ -78,8 +53,8 @@ steps: - promote target: - upstream - depends_on: - - "Sync core with upstream" + branch: + - core environment: TEA_CONFIG: from_secret: tea_config @@ -88,18 +63,14 @@ steps: - echo "$$TEA_CONFIG" > ~/.config/tea/config.yml - tea pulls create --base core --head devos - - name: "Notify failure" + - name: "Notify matrix" image: plugins/matrix when: - status: - - success event: - cron - promote target: - upstream - depends_on: - - "Open pull request for failed merge" settings: homeserver: https://matrix.pub.solar roomid: dfQBqwkhIzrFjMSsxy:pub.solar @@ -107,4 +78,4 @@ steps: from_secret: matrix_username password: from_secret: matrix_password - template: Upstreaming devos into core failed. A pull request has been created https://git.b12f.io/pub-solar/os/pulls + 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)" diff --git a/.drone/setup_ssh.sh b/.drone/setup_ssh.sh index 05424e4c..f4a1bbd4 100755 --- a/.drone/setup_ssh.sh +++ b/.drone/setup_ssh.sh @@ -1,4 +1,7 @@ -#!/bin/bash +#!/usr/bin/env sh + +set -e + # Setup ssh inside container mkdir -p ~/.ssh echo "$GITEA_SSH_KEY" > ~/.ssh/id_rsa diff --git a/.drone/upstream-branch.sh b/.drone/upstream-branch.sh new file mode 100644 index 00000000..0f54386b --- /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 --track origin/"$LOCAL" +git merge "$UPSTREAM" +git push origin "$LOCAL"