From f954801b4e9b9aed117314272a926124e5c642f3 Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Thu, 11 Jul 2024 16:57:02 +0200 Subject: [PATCH] feat: :sparkles: add support for adaptive cards --- cards/release.json | 25 +++++++++++++++++++++++++ plugin/plugin.go | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 cards/release.json diff --git a/cards/release.json b/cards/release.json new file mode 100644 index 0000000..2682034 --- /dev/null +++ b/cards/release.json @@ -0,0 +1,25 @@ +{ + "type": "AdaptiveCard", + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", + "version": "1.6", + "body": [ + { + "type": "TextBlock", + "text": "Publish Adaptive Card Schema", + "wrap": true, + "style": "heading" + }, + { + "type": "TextBlock", + "text": "Tag: 1.0.0", + "wrap": true + } + ], + "actions": [ + { + "type": "Action.OpenUrl", + "title": "View release", + "url": "https://google.com" + } + ] +} diff --git a/plugin/plugin.go b/plugin/plugin.go index 5d82cfc..bb5e98d 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -41,6 +41,12 @@ type Args struct { FetchGitTags bool `envconfig:"PLUGIN_FETCH_GIT_TAGS" default:"true"` } +type ReleaseCard struct { + Title string + Tag string + Url string +} + type TitleTemplateCtx struct { Tag string GiteaUrl string @@ -156,5 +162,15 @@ func Exec(ctx context.Context, args Args) error { releaseURL := fmt.Sprintf("%s/%s/%s/releases/tag/%s", args.GiteaUrl, args.Owner, args.Repo, release.TagName) fmt.Printf("Successfully created release at %s", releaseURL) + writeCard( + args.Pipeline.Card.Path, + "https://gitea.dikurium.ch/InnoPeak/drone-gitea-release/raw/branch/main/card.json", + ReleaseCard{ + Title: title, + Tag: tag, + Url: releaseURL, + }, + ) + return err }