Add dispatch step to update tag in rancher/rancher

This commit is contained in:
Sebastiaan van Steenis 2022-04-26 21:24:15 +02:00
parent f9bafed8ac
commit 7f8a98198e
No known key found for this signature in database
GPG Key ID: B94666BE95B4B9C2
2 changed files with 36 additions and 0 deletions

View File

@ -113,6 +113,26 @@ steps:
include:
- "refs/tags/v2.6.*"
- name: create-pr-in-rancher
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/create-pr-in-rancher
when:
event:
- tag
ref:
include:
- "refs/tags/v2.6.*"
depends_on:
- upload-release-tar
volumes:
- name: docker
host:

16
scripts/create-pr-in-rancher Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
set -ex
REPO="https://api.github.com/repos/rancher/rancher/actions/workflows/replace-env-value.yml/dispatches"
# Only use first two parts, delimited by dot
# v2.6.5 becomes v2.6, end result: release/v2.6
ACTION_TARGET_BRANCH="release/$(echo $DRONE_TAG | cut -f1,2 -d".")"
echo "Dispatching to branch ${ACTION_TARGET_BRANCH} with INPUT_ENVVALUE=${DRONE_TAG}"
# 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":{"INPUT_FILEPATH":"package/Dockerfile","INPUT_ENVVAR":"CATTLE_UI_VERSION","INPUT_ENVVALUE":"'"${DRONE_TAG##v}"'"}}'