No idea what I did or whether it works

This commit is contained in:
Benjamin Bädorf 2021-06-15 01:21:08 +02:00
parent 110909f7a1
commit 8345f3a6f4
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
3 changed files with 27 additions and 41 deletions

View file

@ -1,6 +1,6 @@
kind: pipeline kind: pipeline
type: docker type: docker
name: upstreaming name: Upstreaming
steps: steps:
- name: "Sync upstream to local" - name: "Sync upstream to local"
@ -11,11 +11,13 @@ steps:
- promote - promote
target: target:
- upstream - upstream
branch:
- core
environment: environment:
GITEA_SSH_KEY: GITEA_SSH_KEY:
from_secret: gitea_ssh_key from_secret: gitea_ssh_key
commands: commands:
- sh .drone/setup_ssh.sh - ./.drone/setup_ssh.sh
- git fetch - git fetch
- git checkout devos - git checkout devos
- git remote add devos git@git.b12f.io:pub-solar/devos - git remote add devos git@git.b12f.io:pub-solar/devos
@ -24,7 +26,7 @@ steps:
- git merge -X theirs devos/core - git merge -X theirs devos/core
- git push origin devos - git push origin devos
- name: "Sync core with upstream" - name: "Sync branch with upstream"
image: alpine/git image: alpine/git
when: when:
status: status:
@ -34,39 +36,12 @@ steps:
- promote - promote
target: target:
- upstream - upstream
depends_on:
- "Sync upstream to local"
environment: environment:
GITEA_SSH_KEY: GITEA_SSH_KEY:
from_secret: gitea_ssh_key from_secret: gitea_ssh_key
commands: commands:
- git checkout feat/upstreaming - ./.drone/setup_ssh.sh
- sh .drone/setup_ssh.sh - ./.drone/upstream-branch.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.
- name: "Open pull request for failed merge" - name: "Open pull request for failed merge"
image: nixery.dev/shell/tea image: nixery.dev/shell/tea
@ -78,8 +53,8 @@ steps:
- promote - promote
target: target:
- upstream - upstream
depends_on: branch:
- "Sync core with upstream" - core
environment: environment:
TEA_CONFIG: TEA_CONFIG:
from_secret: tea_config from_secret: tea_config
@ -88,18 +63,14 @@ steps:
- echo "$$TEA_CONFIG" > ~/.config/tea/config.yml - echo "$$TEA_CONFIG" > ~/.config/tea/config.yml
- tea pulls create --base core --head devos - tea pulls create --base core --head devos
- name: "Notify failure" - name: "Notify matrix"
image: plugins/matrix image: plugins/matrix
when: when:
status:
- success
event: event:
- cron - cron
- promote - promote
target: target:
- upstream - upstream
depends_on:
- "Open pull request for failed merge"
settings: settings:
homeserver: https://matrix.pub.solar homeserver: https://matrix.pub.solar
roomid: dfQBqwkhIzrFjMSsxy:pub.solar roomid: dfQBqwkhIzrFjMSsxy:pub.solar
@ -107,4 +78,4 @@ steps:
from_secret: matrix_username from_secret: matrix_username
password: password:
from_secret: matrix_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)"

View file

@ -1,4 +1,7 @@
#!/bin/bash #!/usr/bin/env sh
set -e
# Setup ssh inside container # Setup ssh inside container
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "$GITEA_SSH_KEY" > ~/.ssh/id_rsa echo "$GITEA_SSH_KEY" > ~/.ssh/id_rsa

12
.drone/upstream-branch.sh Normal file
View file

@ -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"