From 0e5bd2bfb839e6c12379dfefb1635ac3d1abc346 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Steenis Date: Mon, 9 May 2022 12:30:44 +0200 Subject: [PATCH] Add workflow to create PR in Rancher on tag --- .drone.yml | 18 ++++++++++++++++++ scripts/dispatch | 25 +++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 scripts/dispatch diff --git a/.drone.yml b/.drone.yml index 8aa7d55c..7479a4d6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -83,6 +83,24 @@ steps: - "refs/tags/*rc*" - "refs/tags/*alpha*" +- name: dispatch + image: curlimages/curl:7.81.0 + user: root + environment: + PAT_USERNAME: + from_secret: pat_username + PAT_TOKEN: + from_secret: github_token + commands: + - apk -U --no-cache add bash + - scripts/dispatch + when: + instance: + include: + - drone-publish.rancher.io + event: + - tag + volumes: - name: socket host: diff --git a/scripts/dispatch b/scripts/dispatch new file mode 100755 index 00000000..820cf41f --- /dev/null +++ b/scripts/dispatch @@ -0,0 +1,25 @@ +#!/bin/bash +set -e +set -x + +REPO="https://api.github.com/repos/rancher/rancher/actions/workflows/go-get.yml/dispatches" + +case $DRONE_TAG in + "v1.3"*) + ACTION_TARGET_BRANCH="release/v2.6" + ;; + *) + echo "Not a valid tag, not dispatching event" + exit 0 +esac + +echo "DRONE_TAG: $DRONE_TAG" +echo "DRONE_COMMIT_AUTHOR: $DRONE_COMMIT_AUTHOR" + +echo "Dispatching to branch ${ACTION_TARGET_BRANCH}" + +# send dispatch event to workflow +curl -XPOST -u "${PAT_USERNAME}:${PAT_TOKEN}" \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Content-Type: application/json" $REPO \ + --data '{"ref": "'"$ACTION_TARGET_BRANCH"'","inputs":{"goget_module":"github.com/rancher/rke","goget_version":"'"$DRONE_TAG"'","source_author":"'"$DRONE_COMMIT_AUTHOR"'"}}'